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