Conditions | 5 |
Paths | 6 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
23 | 53 | public function __construct($year) |
|
24 | { |
||
25 | 53 | if (is_int($year)) { |
|
26 | 17 | $year = (string)$year; |
|
27 | } |
||
28 | |||
29 | 53 | if (!is_string($year) || !ctype_digit($year)) { |
|
30 | 9 | throw new \InvalidArgumentException(sprintf('Expected string or integer and got %s', gettype($year))); |
|
31 | } |
||
32 | |||
33 | 44 | if (4 !== mb_strlen($year)) { |
|
34 | 6 | throw new \LengthException('Expected a full numeric representation of a year.'); |
|
35 | } |
||
36 | |||
37 | 38 | $this->value = $year; |
|
38 | 38 | } |
|
39 | |||
48 |