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 | 137 | 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 | 134 | 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 | 134 | public function get($key) |
|
56 | |||
57 | /** |
||
58 | * Set the value of $key to $value. |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @param mixed $value |
||
62 | * @return $this |
||
63 | */ |
||
64 | 136 | public function set($key, $value) |
|
72 | |||
73 | /** |
||
74 | * Returns a plain array representation of the Value\Container object. |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 137 | public function getArrayCopy() |
|
82 | |||
83 | /** |
||
84 | * Traverses the key using dot notation. Based on the second parameter, it will return the value or if it was set. |
||
85 | * |
||
86 | * @param string $key |
||
87 | * @param bool $returnValue |
||
88 | * @return mixed |
||
89 | */ |
||
90 | 134 | protected function traverse($key, $returnValue = true) |
|
101 | |||
102 | /** |
||
103 | * Uses dot-notation to set a value. |
||
104 | * |
||
105 | * @param string $key |
||
106 | * @param mixed $value |
||
107 | * @return $this |
||
108 | */ |
||
109 | 5 | protected function setTraverse($key, $value) |
|
124 | } |
||
125 |