| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 61 | public function validate(AccountNumber $number): ResultInterface |
|
| 15 | { |
||
| 16 | 61 | $day = (int)substr($number->getSerialNumber(), -5, 2); |
|
| 17 | 61 | $month = (int)substr($number->getSerialNumber(), -7, 2); |
|
| 18 | 61 | $year = (int)substr($number->getSerialNumber(), 0, -7); |
|
| 19 | |||
| 20 | 61 | if (!checkdate($month, $day, $year)) { |
|
| 21 | 54 | return new Failure("Account number is not a valid personal id number"); |
|
| 22 | } |
||
| 23 | |||
| 24 | 23 | return new Success("Valid personal id number"); |
|
| 25 | } |
||
| 26 | } |
||
| 27 |