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