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 | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 9 |
Changes | 0 |
1 | <?php |
||
18 | 22 | public function validate($input): bool |
|
19 | { |
||
20 | // Code ported from jsfromhell.com |
||
21 | 22 | $c = preg_replace('/\D/', '', $input); |
|
22 | |||
23 | 22 | if (11 != mb_strlen($c) || preg_match("/^{$c[0]}{11}$/", $c)) { |
|
24 | 12 | return false; |
|
25 | } |
||
26 | |||
27 | 10 | for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); |
|
28 | |||
29 | 10 | if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { |
|
30 | 4 | return false; |
|
31 | } |
||
32 | |||
33 | 6 | for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); |
|
34 | |||
35 | 6 | if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { |
|
36 | 3 | return false; |
|
37 | } |
||
38 | |||
39 | 3 | return true; |
|
40 | } |
||
42 |