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