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

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

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

    $rest = array_sum($ary) % 11;
    if ($rest != 0 && $rest != 1) {
      $result = 11 - $rest;
    } else {
      $result = $rest;
    }

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