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 | 153 | 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 | 149 | 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 | 140 | public function get($key) |
|
56 | |||
57 | /** |
||
58 | * Removes a value from the container |
||
59 | * |
||
60 | * @param string $key |
||
61 | */ |
||
62 | public function remove($key) |
||
66 | 148 | ||
67 | 4 | /** |
|
68 | * Set the value of $key to $value. |
||
69 | 145 | * |
|
70 | 145 | * @param string $key |
|
71 | * @param mixed $value |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function set($key, $value) |
||
82 | |||
83 | /** |
||
84 | * Returns a plain array representation of the Value\Container object. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function getArrayCopy() |
||
92 | 149 | ||
93 | 149 | /** |
|
94 | 149 | * Traverses the key using dot notation. Based on the second parameter, it will return the value or if it was set. |
|
95 | 10 | * |
|
96 | * @param string $key |
||
97 | 140 | * @param bool $returnValue |
|
98 | 140 | * @return mixed |
|
99 | 140 | */ |
|
100 | protected function traverse($key, $returnValue = true) |
||
111 | 4 | ||
112 | 4 | /** |
|
113 | * Uses dot-notation to set a value. |
||
114 | 4 | * |
|
115 | 4 | * @param string $key |
|
116 | 4 | * @param mixed $value |
|
117 | * @return $this |
||
118 | 4 | */ |
|
119 | 4 | protected function setTraverse($key, $value) |
|
131 | |||
132 | /** |
||
133 | * @param array $keyParts |
||
134 | * @param array $values |
||
135 | */ |
||
136 | private function removeRecursive(array $keyParts, array &$values) |
||
153 | } |
||
154 |