@@ 158-169 (lines=12) @@ | ||
155 | /** |
|
156 | * {@inheritdoc} |
|
157 | */ |
|
158 | public function get($key, $default = null) |
|
159 | { |
|
160 | KeyUtil::validate($key); |
|
161 | ||
162 | $data = $this->load(); |
|
163 | ||
164 | if (!array_key_exists($key, $data)) { |
|
165 | return $default; |
|
166 | } |
|
167 | ||
168 | return $this->unserializeValue($data[$key]); |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * {@inheritdoc} |
|
@@ 174-185 (lines=12) @@ | ||
171 | /** |
|
172 | * {@inheritdoc} |
|
173 | */ |
|
174 | public function getOrFail($key) |
|
175 | { |
|
176 | KeyUtil::validate($key); |
|
177 | ||
178 | $data = $this->load(); |
|
179 | ||
180 | if (!array_key_exists($key, $data)) { |
|
181 | throw NoSuchKeyException::forKey($key); |
|
182 | } |
|
183 | ||
184 | return $this->unserializeValue($data[$key]); |
|
185 | } |
|
186 | ||
187 | /** |
|
188 | * {@inheritdoc} |
|
@@ 234-249 (lines=16) @@ | ||
231 | /** |
|
232 | * {@inheritdoc} |
|
233 | */ |
|
234 | public function remove($key) |
|
235 | { |
|
236 | KeyUtil::validate($key); |
|
237 | ||
238 | $data = $this->load(); |
|
239 | ||
240 | if (!array_key_exists($key, $data)) { |
|
241 | return false; |
|
242 | } |
|
243 | ||
244 | unset($data[$key]); |
|
245 | ||
246 | $this->save($data); |
|
247 | ||
248 | return true; |
|
249 | } |
|
250 | ||
251 | /** |
|
252 | * {@inheritdoc} |