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