1 | <?php |
||
17 | abstract class StaticDictionary implements StaticDictionaryInterface |
||
18 | { |
||
19 | /** @var array Dictionary values (to be overloaded). */ |
||
20 | protected static $dictionary = []; |
||
21 | |||
22 | /** |
||
23 | * Returns dictionary. |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | 6 | protected static function dictionary() |
|
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | 1 | public static function all() |
|
36 | { |
||
37 | 1 | return static::dictionary(); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | 1 | public static function get($key) |
|
44 | { |
||
45 | 1 | $dictionary = static::dictionary(); |
|
46 | |||
47 | 1 | if (array_key_exists($key, $dictionary)) { |
|
48 | 1 | return $dictionary[$key]; |
|
49 | } |
||
50 | else { |
||
51 | 1 | return static::FALLBACK === null ? null : $dictionary[static::FALLBACK]; |
|
52 | } |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 1 | public static function has($key) |
|
59 | { |
||
60 | 1 | return array_key_exists($key, static::dictionary()); |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 1 | public static function find($value) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public static function keys() |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 1 | public static function values() |
|
88 | } |
||
89 |