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 | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public function validate($input) |
||
| 24 | { |
||
| 25 | if (!is_scalar($input)) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!preg_match('/^\d{10}$/', (string) $input)) { |
||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | $weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]; |
||
| 34 | |||
| 35 | $targetControlNumber = $input[9]; |
||
| 36 | $calculateControlNumber = 0; |
||
| 37 | |||
| 38 | for ($i = 0; $i < 9; ++$i) { |
||
| 39 | $calculateControlNumber += $input[$i] * $weights[$i]; |
||
| 40 | } |
||
| 41 | |||
| 42 | $calculateControlNumber = $calculateControlNumber % 11; |
||
| 43 | |||
| 44 | return $targetControlNumber == $calculateControlNumber; |
||
| 45 | } |
||
| 46 | } |
||
| 47 |