Total Complexity | 9 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | final class Language implements JsonSerializable, ValueObject |
||
15 | { |
||
16 | /** @var string */ |
||
17 | private $name; |
||
18 | /** @var string */ |
||
19 | private $code; |
||
20 | |||
21 | /** |
||
22 | * @param string|null $code a representation of one of this codes: https://en.wikipedia.org/wiki/Language_code |
||
23 | */ |
||
24 | public function __construct(string $name, ?string $code = null) |
||
25 | { |
||
26 | if ($name === '') { |
||
27 | throw new InvalidArgumentException('Name should not be empty string'); |
||
28 | } |
||
29 | |||
30 | $this->name = $name; |
||
31 | $this->code = $code; |
||
32 | } |
||
33 | |||
34 | public function getName() : string |
||
35 | { |
||
36 | return $this->name; |
||
37 | } |
||
38 | |||
39 | public function getCode() : ?string |
||
40 | { |
||
41 | return $this->code; |
||
42 | } |
||
43 | |||
44 | public function equals(?ValueObject $object) : bool |
||
52 | } |
||
53 | |||
54 | public function __toString() : string |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | * |
||
62 | * @return mixed[] |
||
63 | */ |
||
64 | public function jsonSerialize() : array |
||
69 | ]; |
||
70 | } |
||
72 |