Conditions | 5 |
Paths | 6 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
23 | 49 | public function __construct($month) |
|
24 | { |
||
25 | 49 | if (is_int($month)) { |
|
26 | 16 | $month = (string)$month; |
|
27 | } |
||
28 | |||
29 | 49 | if (!is_string($month) || !ctype_digit($month)) { |
|
30 | 8 | throw new \InvalidArgumentException(sprintf('Expected string or integer and got %s', gettype($month))); |
|
31 | } |
||
32 | |||
33 | 41 | if (!in_array((int)$month, range(1, 12), true)) { |
|
34 | 5 | throw new \OutOfRangeException('Expected a numeric representation of a month.'); |
|
35 | } |
||
36 | |||
37 | 36 | $this->value = str_pad($month, 2, 0, STR_PAD_LEFT); |
|
38 | 36 | } |
|
39 | |||
48 |