| 1 | <?php  | 
            ||
| 15 | final class Hour extends Embeddable  | 
            ||
| 16 | { | 
            ||
| 17 | /**  | 
            ||
| 18 | * @param string|int $value  | 
            ||
| 19 | *  | 
            ||
| 20 | * @throws \InvalidArgumentException  | 
            ||
| 21 | * @throws \OutOfRangeException  | 
            ||
| 22 | */  | 
            ||
| 23 | 62 | public function __construct($value)  | 
            |
| 24 |     { | 
            ||
| 25 | 62 |         if (is_int($value)) { | 
            |
| 26 | 19 | $value = (string)$value;  | 
            |
| 27 | }  | 
            ||
| 28 | |||
| 29 | 62 |         if (!is_string($value) || !ctype_digit($value)) { | 
            |
| 30 | 8 |             throw new \InvalidArgumentException(sprintf('Expected string or integer and got %s', gettype($value))); | 
            |
| 31 | }  | 
            ||
| 32 | |||
| 33 | 54 |         if (!in_array((int)$value, range(0, 23), true)) { | 
            |
| 34 | 7 |             throw new \OutOfRangeException('Expected a numeric representation of an hour.'); | 
            |
| 35 | }  | 
            ||
| 36 | |||
| 37 | 47 | $this->value = str_pad($value, 2, 0, STR_PAD_LEFT);  | 
            |
| 38 | 47 | }  | 
            |
| 39 | |||
| 40 | /**  | 
            ||
| 41 |      * {@inheritdoc} | 
            ||
| 42 | */  | 
            ||
| 43 | 7 | public function equals(Embeddable $object)  | 
            |
| 47 | }  | 
            ||
| 48 |