Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
34 | 8 | public function __construct($postalAccount) |
|
35 | { |
||
36 | 8 | if (!preg_match(self::PATTERN, $postalAccount)) { |
|
37 | 1 | throw new \InvalidArgumentException('Postal account number is not properly formatted.'); |
|
38 | } |
||
39 | |||
40 | 7 | $parts = explode('-', $postalAccount); |
|
41 | 7 | if (!self::checkPrefix($parts[0])) { |
|
42 | 1 | throw new \InvalidArgumentException('Postal account number has an invalid prefix.'); |
|
43 | } |
||
44 | |||
45 | 6 | $this->prefix = (int) $parts[0]; |
|
46 | 6 | $this->number = (int) $parts[1]; |
|
47 | 6 | $this->checkDigit = (int) $parts[2]; |
|
48 | 6 | } |
|
49 | |||
79 |