1 | <?php |
||
20 | class Settings implements \IteratorAggregate |
||
21 | { |
||
22 | const DEFAULT_FILENAME = '.settings.json'; |
||
23 | |||
24 | /** @var array The settings */ |
||
25 | private $data; |
||
26 | |||
27 | /** |
||
28 | * Contruct a settings object with the given data. |
||
29 | * |
||
30 | * @param $data = [] |
||
31 | */ |
||
32 | 13 | public function __construct($data = []) |
|
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 1 | public function getIterator() |
|
44 | |||
45 | /** |
||
46 | * Returns the number of key-value mappings in the settings map. |
||
47 | * |
||
48 | * @return int the number of key-value mappings in the settings map. |
||
49 | */ |
||
50 | 1 | public function count() |
|
54 | |||
55 | /** |
||
56 | * Returns true if the settings map contains no key-value mappings. |
||
57 | * |
||
58 | * @return bool true if the settings map contains no key-value mappings. |
||
59 | */ |
||
60 | 2 | public function isEmpty() |
|
64 | |||
65 | /** |
||
66 | * Returns true if the settings map contains a mapping for the specified key. |
||
67 | * |
||
68 | * @param string $key |
||
69 | * @return bool true if the settings map contains a mapping for the specified key. |
||
70 | */ |
||
71 | 6 | public function containsKey($key) |
|
75 | |||
76 | /** |
||
77 | * Returns true if the settings map maps one or more keys to the specified value. |
||
78 | * |
||
79 | * @param string $value |
||
80 | * @return bool true if the settings map maps one or more keys to the specified value. |
||
81 | */ |
||
82 | 1 | public function containsValue($value) |
|
86 | |||
87 | /** |
||
88 | * Returns the value to which the specified key is mapped, or null if the settings map contains no mapping for the key. |
||
89 | * |
||
90 | * @param string $key |
||
91 | * @return string the value to which the specified key is mapped, or null if the settings map contains no mapping for the key. |
||
92 | */ |
||
93 | 4 | public function get($key) |
|
97 | |||
98 | /** |
||
99 | * Associates the specified value with the specified key in the settings map. |
||
100 | * |
||
101 | * @param string $key |
||
102 | * @param string $value |
||
103 | * @return $this |
||
104 | */ |
||
105 | 2 | public function set($key, $value) |
|
111 | |||
112 | /** |
||
113 | * Removes the mapping for the specified key from the settings map if present. |
||
114 | * |
||
115 | * @param string $key |
||
116 | * @return $this |
||
117 | */ |
||
118 | 1 | public function remove($key) |
|
124 | |||
125 | /** |
||
126 | * Removes all of the mappings from the settings map. |
||
127 | * |
||
128 | * @return $this |
||
129 | */ |
||
130 | 2 | public function clear() |
|
136 | |||
137 | /** |
||
138 | * Load the settings file from the given location. |
||
139 | * |
||
140 | * @param $path = self::DEFAULT_FILENAME |
||
141 | * @return $this |
||
142 | * @throws FileException on failure. |
||
143 | * @throws \UnexpectedValueException on failure. |
||
144 | */ |
||
145 | 4 | public function load($path = self::DEFAULT_FILENAME) |
|
157 | |||
158 | /** |
||
159 | * Save the settings file at the given location. |
||
160 | * |
||
161 | * @param $path = self::DEFAULT_FILENAME |
||
162 | * @return $this |
||
|
|||
163 | * @throws FileException on failure. |
||
164 | */ |
||
165 | 1 | public function save($path = self::DEFAULT_FILENAME) |
|
171 | } |
||
172 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.