<?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_A0 implements IPruefziffer
{
  public static function check($pKtoNr, $pBlz, $pGewichtung = array(), $pPruefZifferStelle = 9)
  {
    if (strlen((string)($pKtoNr * 1)) == 3) {
      return true;
    }

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

    $gewichtung = array(0, 2, 4, 8, 5, 10, 0, 0, 0, 0);

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

    $summe = array_sum($ary);

    $result = ((11 - ($summe % 11)) % 11) % 10;

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