We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 5 |
| Paths | 6 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 23 | public function validate($input) |
|
| 27 | { |
||
| 28 | 23 | if (!ctype_digit($input)) { |
|
| 29 | 3 | return false; |
|
| 30 | } |
||
| 31 | |||
| 32 | 20 | if (strlen($input) !== 9) { |
|
| 33 | 3 | return false; |
|
| 34 | } |
||
| 35 | |||
| 36 | 17 | $sum = -1 * $input[8]; |
|
| 37 | 17 | for ($i = 9; $i > 1; --$i) { |
|
| 38 | 17 | $sum += $i * $input[9 - $i]; |
|
| 39 | 17 | } |
|
| 40 | |||
| 41 | 17 | return $sum !== 0 && $sum % 11 === 0; |
|
| 42 | } |
||
| 43 | } |
||
| 44 |