1 | <?php declare(strict_types = 1); |
||
16 | class MutableContainer extends AbstractContainer implements MutableContainerContract |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var ServiceDecoratorContract |
||
21 | */ |
||
22 | private $decorator; |
||
23 | |||
24 | /** |
||
25 | * @var ServiceInflectorContract |
||
26 | */ |
||
27 | private $inflector; |
||
28 | |||
29 | /** |
||
30 | * @inheritDoc |
||
31 | */ |
||
32 | 44 | public function __construct() |
|
39 | |||
40 | |||
41 | /** |
||
42 | * @inheritDoc |
||
43 | */ |
||
44 | 4 | public function addDecorator(string $id, $decorator) |
|
55 | |||
56 | /** |
||
57 | * @inheritDoc |
||
58 | */ |
||
59 | 4 | public function addInflection(string $id, string $method, array $arguments = []) |
|
63 | |||
64 | /** |
||
65 | * @inheritDoc |
||
66 | */ |
||
67 | 12 | public function bind(string $id, $service) |
|
77 | |||
78 | /** |
||
79 | * @inheritDoc |
||
80 | */ |
||
81 | 12 | public function factory(string $id, $callable, $shared = false) |
|
92 | |||
93 | /** |
||
94 | * @inheritDoc |
||
95 | */ |
||
96 | 36 | protected function instantiateService(string $id, array $arguments) |
|
103 | |||
104 | /** |
||
105 | * @param ServiceDecoratorContract $decorator |
||
106 | */ |
||
107 | 44 | protected function setDecorator(ServiceDecoratorContract $decorator) |
|
111 | |||
112 | /** |
||
113 | * @param ServiceInflectorContract $inflector |
||
114 | */ |
||
115 | 44 | protected function setInflector(ServiceInflectorContract $inflector) |
|
119 | |||
120 | /** |
||
121 | * @param string $id |
||
122 | * @param string $class |
||
123 | * @return void |
||
124 | * @throws InvalidArgumentException |
||
125 | */ |
||
126 | 8 | private function bindClass(string $id, string $class) |
|
135 | |||
136 | /** |
||
137 | * @param string $id |
||
138 | * @param object $instance |
||
139 | * @return void |
||
140 | * @throws InvalidArgumentException |
||
141 | */ |
||
142 | 4 | private function bindInstance(string $id, $instance) |
|
151 | |||
152 | /** |
||
153 | * Check if subject service is an object instance. |
||
154 | * |
||
155 | * @param mixed $service |
||
156 | * @return bool |
||
157 | */ |
||
158 | 4 | private function isConcrete($service): bool |
|
162 | |||
163 | /** |
||
164 | * Verifies that provided callable can be called by service container. |
||
165 | * |
||
166 | * @param Invokable $reflectedCallable |
||
167 | * @return bool |
||
168 | */ |
||
169 | 12 | private function isResolvableCallable(Invokable $reflectedCallable): bool |
|
178 | |||
179 | /** |
||
180 | * Registers binding. |
||
181 | * After this method call binding can be resolved by container. |
||
182 | * |
||
183 | * @param string $id |
||
184 | * @param bool $shared |
||
185 | * @param Closure $registrationCallback |
||
186 | * @return void |
||
187 | */ |
||
188 | 23 | private function register(string $id, bool $shared, Closure $registrationCallback) |
|
206 | |||
207 | /** |
||
208 | * Validate service identifier. Throw an Exception in case of invalid value. |
||
209 | * |
||
210 | * @param string $id |
||
211 | * @return void |
||
212 | * @throws InvalidArgumentException |
||
213 | */ |
||
214 | 23 | private function validateId(string $id) |
|
222 | |||
223 | } |