<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */
class Pruefziffer_35 implements IPruefziffer
{
  public static function check($pKtoNr, $pBlz, $pGewichtung = array(), $pPruefZifferStelle = 9)
  {
    $gewichtung = array(0, 2, 3, 4, 5, 6, 7, 8, 9, 10);

    $ktoNr = str_pad($pKtoNr, 10, '0', STR_PAD_LEFT);
    $strZahl = strrev($ktoNr);

    $ary = PruefZiffHelpers::gewichten($strZahl, $gewichtung);

    $rest = array_sum($ary) % 11;

    if ($rest == 10) {
      $result = ($ktoNr[8] == $ktoNr[9]);
    } else {
      $result = ($rest == $ktoNr[$pPruefZifferStelle]);
    }

    return $result;
  }
}