-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathStorageArray.php
72 lines (62 loc) · 1.23 KB
/
StorageArray.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @link https://github.com/illuminatech
* @copyright Copyright (c) 2019 Illuminatech
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
*/
namespace Illuminatech\Config;
/**
* StorageArray uses internal array for the config storage.
*
* This class can be useful in unit tests.
*
* @author Paul Klimov <[email protected]>
* @since 1.0
*/
class StorageArray implements StorageContract
{
/**
* @var array stored data.
*/
protected $data = [];
/**
* Constructor.
*
* @param array $data data to be stored.
*/
public function __construct(array $data = [])
{
$this->data = $data;
}
/**
* {@inheritDoc}
*/
public function save(array $values): bool
{
$this->data = array_merge($this->data, $values);
return true;
}
/**
* {@inheritDoc}
*/
public function get(): array
{
return $this->data;
}
/**
* {@inheritDoc}
*/
public function clear(): bool
{
$this->data = [];
return true;
}
/**
* {@inheritDoc}
*/
public function clearValue($key): bool
{
unset($this->data[$key]);
return true;
}
}