| Conditions | 6 |
| Paths | 6 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 23 | 60 | public function __construct($number) |
|
| 24 | { |
||
| 25 | 60 | if (is_int($number)) { |
|
| 26 | 22 | $number = (string)$number; |
|
| 27 | 11 | } |
|
| 28 | |||
| 29 | 60 | 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 | 46 | if ((int)$number > 999 || (int)$number < 1) { |
|
| 34 | 2 | throw new \OutOfRangeException(sprintf('Expected a number between 1 and 999 (got %d)', (int)$number)); |
|
| 35 | } |
||
| 36 | |||
| 37 | 44 | $this->value = str_pad((string)$number, 3, 0, STR_PAD_LEFT); |
|
| 38 | 44 | } |
|
| 39 | |||
| 48 |