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

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

    if ($ktoNr[0] != 0) {
      return false;
    } elseif ($ktoNr[1] == 9) {
      return true;
    }
    $strZahl = strrev($ktoNr);

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

    $rest = array_sum($ary) % 11;

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

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