Conditions | 6 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
23 | public static function validate($value) |
||
24 | { |
||
25 | if (!is_numeric($value)) { |
||
26 | return false; |
||
27 | } |
||
28 | |||
29 | $stringLength = strlen($value); |
||
30 | |||
31 | if ($stringLength !== 9 && $stringLength !== 8) { |
||
32 | return false; |
||
33 | } |
||
34 | |||
35 | $sum = 0; |
||
36 | $multiplier = $stringLength; |
||
37 | for ($counter = 0; $counter < $stringLength; $counter++, $multiplier--) { |
||
38 | if ($multiplier == 1) { |
||
39 | $multiplier = -1; |
||
40 | } |
||
41 | |||
42 | $sum += substr($value, $counter, 1) * $multiplier; |
||
43 | } |
||
44 | |||
45 | return $sum % 11 === 0; |
||
46 | } |
||
47 | } |
||
48 |