| 1 | <?php  | 
            ||
| 15 | final class Year extends Embeddable  | 
            ||
| 16 | { | 
            ||
| 17 | /**  | 
            ||
| 18 | * @param string|int $year  | 
            ||
| 19 | *  | 
            ||
| 20 | * @throws \InvalidArgumentException  | 
            ||
| 21 | * @throws \LengthException If received value is not a full numeric representation of a year.  | 
            ||
| 22 | */  | 
            ||
| 23 | 53 | public function __construct($year)  | 
            |
| 24 |     { | 
            ||
| 25 | 53 |         if (is_int($year)) { | 
            |
| 26 | 17 | $year = (string)$year;  | 
            |
| 27 | }  | 
            ||
| 28 | |||
| 29 | 53 |         if (!is_string($year) || !ctype_digit($year)) { | 
            |
| 30 | 9 |             throw new \InvalidArgumentException(sprintf('Expected string or integer and got %s', gettype($year))); | 
            |
| 31 | }  | 
            ||
| 32 | |||
| 33 | 44 |         if (4 !== mb_strlen($year)) { | 
            |
| 34 | 6 |             throw new \LengthException('Expected a full numeric representation of a year.'); | 
            |
| 35 | }  | 
            ||
| 36 | |||
| 37 | 38 | $this->value = $year;  | 
            |
| 38 | 38 | }  | 
            |
| 39 | |||
| 40 | /**  | 
            ||
| 41 |      * {@inheritdoc} | 
            ||
| 42 | */  | 
            ||
| 43 | 6 | public function equals(Embeddable $object)  | 
            |
| 47 | }  | 
            ||
| 48 |