| Conditions | 6 |
| Paths | 6 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 68 | public function __construct($number) |
|
| 24 | { |
||
| 25 | 68 | if (is_int($number)) { |
|
| 26 | 22 | $number = (string)$number; |
|
| 27 | } |
||
| 28 | |||
| 29 | 68 | if (!is_string($number) || !ctype_digit($number)) { |
|
| 30 | 14 | throw new \InvalidArgumentException(sprintf('Expected string or integer and got %s', gettype($number))); |
|
| 31 | } |
||
| 32 | |||
| 33 | 54 | if ((int)$number > 999 || (int)$number < 1) { |
|
| 34 | 4 | throw new \OutOfRangeException(sprintf('Expected a number between 1 and 999 (got %d)', (int)$number)); |
|
| 35 | } |
||
| 36 | |||
| 37 | 50 | $this->value = str_pad((string)$number, 3, 0, STR_PAD_LEFT); |
|
| 38 | 50 | } |
|
| 39 | |||
| 48 |