1 | <?php |
||
18 | class Container implements ContainerInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $dicValues = []; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $dicObjects = []; |
||
29 | |||
30 | /** |
||
31 | * Set a DIC value. |
||
32 | * |
||
33 | * Wrap objects provided in a closure for lazy loading. |
||
34 | * |
||
35 | * @param string $key |
||
36 | * @param mixed $value |
||
37 | * @return Container |
||
38 | */ |
||
39 | 20 | public function set($key, $value) |
|
46 | |||
47 | /** |
||
48 | * Check if a DIC value/object exists. |
||
49 | * |
||
50 | * @param string $key |
||
51 | * @return bool |
||
52 | */ |
||
53 | 20 | public function has($key) |
|
57 | |||
58 | /** |
||
59 | * @param string $key |
||
60 | * @return bool |
||
61 | */ |
||
62 | 2 | public function hasInstance($key) |
|
66 | |||
67 | /** |
||
68 | * Get the shared instance of a DIC object, or a DIC value if it's not an object. |
||
69 | * |
||
70 | * @param string $key |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 20 | public function get($key) |
|
93 | |||
94 | /** |
||
95 | * Get new instance of a DIC object. |
||
96 | * |
||
97 | * @param string $key |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 3 | public function getNew($key) |
|
110 | |||
111 | /** |
||
112 | * Destroy a DIC object instance. |
||
113 | * |
||
114 | * Will force a new object to be created on next call. |
||
115 | * |
||
116 | * @param string $key |
||
117 | */ |
||
118 | 1 | public function destroyInstance($key) |
|
122 | |||
123 | /** |
||
124 | * Destroy all DIC object instances. |
||
125 | * |
||
126 | * Will force new objects to be created on next call. |
||
127 | */ |
||
128 | 1 | public function destroyAllInstances() |
|
136 | |||
137 | /** |
||
138 | * Magic method to get or set DIC values. |
||
139 | * |
||
140 | * @param string $name |
||
141 | * @param array $arguments |
||
142 | * @return mixed |
||
143 | */ |
||
144 | 5 | public function __call($name, $arguments) |
|
168 | } |
||
169 |