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