We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 6 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 27 | public function validate($input) |
|
| 15 | { |
||
| 16 | 27 | $c = preg_replace('/\D/', '', $input); |
|
| 17 | |||
| 18 | 27 | if (strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) { |
|
| 19 | 10 | return false; |
|
| 20 | } |
||
| 21 | |||
| 22 | 17 | $r = [3,2,9,8,7,6,5,4,3,2]; |
|
| 23 | |||
| 24 | 17 | for ($n = 0, $i = 0; $i <= 9; $n += $c[$i] * $r[$i++]); |
|
| 25 | |||
| 26 | 17 | if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { |
|
| 27 | 4 | return false; |
|
| 28 | } |
||
| 29 | |||
| 30 | 13 | return true; |
|
| 31 | } |
||
| 32 | } |
||
| 33 |