| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 5 | class Language |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | private $value; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var string[] |
||
| 14 | */ |
||
| 15 | private $supportedLanguages = [ |
||
| 16 | 'nl', |
||
| 17 | 'fr', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $value |
||
| 22 | */ |
||
| 23 | public function __construct(string $value) |
||
| 24 | { |
||
| 25 | if (!in_array($value, $this->supportedLanguages)) { |
||
| 26 | throw new \InvalidArgumentException( |
||
| 27 | 'Given language '.$value.' is not supported, only nl en fr are allowed.' |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | $this->value = $value; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | public function toNative(): string |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param Language $language |
||
| 44 | * |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | public function equals(Language $language): bool |
||
| 50 | } |
||
| 51 | } |
||
| 52 |