We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 8 | private function isValid($input): bool |
|
| 32 | { |
||
| 33 | 8 | $sum = 0; |
|
| 34 | 8 | $numDigits = strlen($input); |
|
| 35 | 8 | $parity = $numDigits % 2; |
|
| 36 | 8 | for ($i = 0; $i < $numDigits; ++$i) { |
|
| 37 | 8 | $digit = substr($input, $i, 1); |
|
| 38 | 8 | if ($parity == ($i % 2)) { |
|
| 39 | 8 | $digit <<= 1; |
|
| 40 | 8 | if (9 < $digit) { |
|
| 41 | 4 | $digit = $digit - 9; |
|
| 42 | } |
||
| 43 | } |
||
| 44 | 8 | $sum += $digit; |
|
| 45 | } |
||
| 46 | |||
| 47 | 8 | return 0 == ($sum % 10); |
|
| 48 | } |
||
| 49 | } |
||
| 50 |