1 | <?php |
||
16 | class Container |
||
17 | { |
||
18 | /** |
||
19 | * Contains the values (either input or output). |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $values = []; |
||
24 | |||
25 | /** |
||
26 | * Construct the Value\Container. |
||
27 | * |
||
28 | * @param array $values |
||
29 | */ |
||
30 | 165 | public function __construct(array $values = []) |
|
34 | |||
35 | /** |
||
36 | * Determines whether or not the container has a value for key $key. |
||
37 | * |
||
38 | * @param string $key |
||
39 | * @return bool |
||
40 | */ |
||
41 | 159 | public function has($key) |
|
45 | |||
46 | /** |
||
47 | * Returns the value for the key $key, or null if the value doesn't exist. |
||
48 | * |
||
49 | * @param string $key |
||
50 | * @return mixed |
||
51 | */ |
||
52 | 148 | public function get($key) |
|
56 | |||
57 | /** |
||
58 | * Removes a value from the container |
||
59 | * |
||
60 | * @param string $key |
||
61 | */ |
||
62 | 8 | public function remove($key) |
|
66 | |||
67 | /** |
||
68 | * Set the value of $key to $value. |
||
69 | * |
||
70 | * @param string $key |
||
71 | * @param mixed $value |
||
72 | * @return $this |
||
73 | */ |
||
74 | 152 | public function set($key, $value) |
|
82 | |||
83 | /** |
||
84 | * Returns a plain array representation of the Value\Container object. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | 165 | public function getArrayCopy() |
|
92 | |||
93 | /** |
||
94 | * Traverses the key using dot notation. Based on the second parameter, it will return the value or if it was set. |
||
95 | * |
||
96 | * @param string $key |
||
97 | * @param bool $returnValue |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 159 | protected function traverse($key, $returnValue = true) |
|
111 | |||
112 | /** |
||
113 | * Uses dot-notation to set a value. |
||
114 | * |
||
115 | * @param string $key |
||
116 | * @param mixed $value |
||
117 | * @return $this |
||
118 | */ |
||
119 | 4 | protected function setTraverse($key, $value) |
|
131 | |||
132 | /** |
||
133 | * @param array $keyParts |
||
134 | * @param array $values |
||
135 | */ |
||
136 | 8 | private function removeRecursive(array $keyParts, array &$values) |
|
155 | } |
||
156 |