| Conditions | 3 |
| Paths | 2 |
| Total Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public static function validateCheckDigit(IdInterface $id): void |
||
| 18 | { |
||
| 19 | $number = (string)preg_replace('/[^0-9]/', '', $id->getId()); |
||
| 20 | |||
| 21 | if (substr($number, -1) !== self::calculateCheckDigit(substr($number, 0, -1) ?: '')) { |
||
| 22 | throw new InvalidCheckDigitException("Invalid check digit in {$id->getId()}"); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 46 |