Conditions | 4 |
Paths | 5 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public static function validate($abn) |
||
20 | { |
||
21 | $weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; |
||
22 | $sum = 0; |
||
23 | $abn = preg_replace('/[^0-9]/', '', $abn); |
||
24 | $abn = Utils::unDecorate($abn, [' ']); |
||
25 | if (mb_strlen($abn) !== 11) { |
||
26 | return false; |
||
27 | } |
||
28 | $abn[0] = ((int)$abn[0] - 1); // Subtract one from first digit |
||
29 | foreach (str_split($abn) as $key => $digit) { |
||
30 | $sum += ($digit * $weights[$key]); |
||
31 | } |
||
32 | if (($sum % 89) != 0) { |
||
33 | return false; |
||
34 | } |
||
35 | return true; |
||
36 | } |
||
37 | } |
||
38 |