| Conditions | 6 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 62 | public static function assertValidIDCard($id) |
||
| 63 | { |
||
| 64 | if (!is_numeric($id)) { |
||
| 65 | throw new \InvalidArgumentException(sprintf('The id "%s" card contains the non-numeric characters', $id)); |
||
| 66 | } |
||
| 67 | $length = strlen($id); |
||
| 68 | if ($length !== 15 && $length !== 18) { |
||
| 69 | throw new \InvalidArgumentException(sprintf('The id "%s" card length should be 15 numbers or 18 numbers, given %d', $id, $length)); |
||
| 70 | } |
||
| 71 | $convertedId = $id; |
||
| 72 | if ($length === 15) { |
||
| 73 | $convertedId = IDCardUtils::convertIDCard15to18($id); |
||
| 74 | } |
||
| 75 | if (!IDCardUtils::check18IDCard($convertedId)) { |
||
| 76 | throw new \InvalidArgumentException(sprintf('The Id card "%s" is invalid', $id)); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | } |