| Conditions | 7 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | public function isValid($input = null) |
||
| 17 | { |
||
| 18 | if (!is_numeric($input)) { |
||
| 19 | $this->violations[] = 'numeric'; |
||
| 20 | |||
| 21 | return false; |
||
| 22 | } |
||
| 23 | |||
| 24 | $input = (string) $input; |
||
| 25 | $length = strlen($input); |
||
| 26 | |||
| 27 | if ($length < 13 || $length > 15) { |
||
| 28 | $this->violations[] = 'length'; |
||
| 29 | |||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($length == 13) { |
||
| 34 | $result = floor(($input / 10) % 11); |
||
| 35 | |||
| 36 | return ($result == 10 ? $input[12] == 0 : $input[12] == $result); |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($length == 15) { |
||
| 40 | $result = floor(($input / 10) % 13); |
||
| 41 | |||
| 42 | return ($input[14] == ($result % 10)); |
||
| 43 | } |
||
| 44 | |||
| 45 | return false; |
||
| 46 | } |
||
| 48 |