Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Language
66.67% covered (warning)
66.67%
2 / 3
66.67% covered (warning)
66.67%
2 / 3
3.33
0.00% covered (danger)
0.00%
0 / 1
 requiresActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOptions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace Apie\IanaValueObjects;
3
4use Apie\Core\Lists\StringSet;
5use Apie\Core\ValueObjects\Interfaces\LimitedOptionsInterface;
6use Apie\Core\ValueObjects\Interfaces\StringValueObjectInterface;
7
8/**
9 * All languages registered in the IANA Language Subtag Registry.
10 *
11 * This one only contains the main languages, so no subtags like "en-US" or "zh-yue" are included.
12 * For those, use the LanguageSubtag value object.
13 *
14 * @see https://www.iana.org/assignments/language-subtag-registry
15 *
16 * Any language that is not active anymore can be used as well (for data integrity).
17 */
18final class Language implements StringValueObjectInterface, LimitedOptionsInterface
19{
20    use IsLanguageSubtag;
21
22    protected static function requiresActive(): bool
23    {
24        return false;
25    }
26
27    protected static function getData(): array
28    {
29        return require __DIR__ . '/../fixtures/languages.php';
30    }
31
32    public static function getOptions(): StringSet
33    {
34        return new StringSet(array_keys(static::getData()));
35    }
36}