<?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_56 implements IPruefziffer
{
  public static function check($pKtoNr, $pBlz, $pGewichtung = array(), $pPruefZifferStelle = 9)
  {
    $gewichtung = array(0, 2, 3, 4, 5, 6, 7, 2, 3, 4);

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

    $ary = PruefZiffHelpers::gewichten($strZahl, $gewichtung);
    $result = 11 - (array_sum($ary) % 11);

    if ($ktoNr[0] == 9 && $result >= 10) {
      $result -= 3;
    }

    return ($result == $ktoNr[$pPruefZifferStelle]);
  }
}