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