We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 16 | 17 | public function validate($input) |
|
| 17 | { |
||
| 18 | 17 | if (!preg_match('/^\d{11}$/', $input)) { |
|
| 19 | 6 | return false; |
|
| 20 | } |
||
| 21 | |||
| 22 | 11 | $weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3]; |
|
| 23 | |||
| 24 | 11 | $targetControlNumber = $input[10]; |
|
| 25 | 11 | $calculateControlNumber = 0; |
|
| 26 | |||
| 27 | 11 | for ($i = 0; $i < 10; $i++) { |
|
| 28 | 11 | $calculateControlNumber += $input[$i] * $weights[$i]; |
|
| 29 | 11 | } |
|
| 30 | |||
| 31 | 11 | $calculateControlNumber = (10 - $calculateControlNumber % 10) % 10; |
|
| 32 | |||
| 33 | 11 | return $targetControlNumber == $calculateControlNumber; |
|
| 34 | } |
||
| 35 | } |
||
| 36 |