1 | <?php declare(strict_types = 1); |
||
17 | class MutableContainer extends AbstractContainer implements MutableContainerContract |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var ServiceDecoratorContract |
||
22 | */ |
||
23 | private $decorator; |
||
24 | |||
25 | /** |
||
26 | * @var ServiceInflectorContract |
||
27 | */ |
||
28 | private $inflector; |
||
29 | |||
30 | /** |
||
31 | * @inheritDoc |
||
32 | */ |
||
33 | 31 | public function __construct() |
|
42 | |||
43 | |||
44 | /** |
||
45 | * @inheritDoc |
||
46 | */ |
||
47 | 4 | public function addDecorator(string $id, $decorator) |
|
58 | |||
59 | /** |
||
60 | * @inheritDoc |
||
61 | */ |
||
62 | 4 | public function addInflection(string $id, string $method, array $arguments = []) |
|
66 | |||
67 | /** |
||
68 | * @inheritDoc |
||
69 | */ |
||
70 | 10 | public function bind(string $id, $service) |
|
80 | |||
81 | /** |
||
82 | * @inheritDoc |
||
83 | */ |
||
84 | 12 | public function factory(string $id, $callable, $shared = false) |
|
95 | |||
96 | /** |
||
97 | * @inheritDoc |
||
98 | */ |
||
99 | 27 | protected function instantiateService(string $id, array $arguments) |
|
106 | |||
107 | /** |
||
108 | * @param ServiceDecoratorContract $decorator |
||
109 | */ |
||
110 | 31 | protected function setDecorator(ServiceDecoratorContract $decorator) |
|
114 | |||
115 | /** |
||
116 | * @param ServiceInflectorContract $inflector |
||
117 | */ |
||
118 | 31 | protected function setInflector(ServiceInflectorContract $inflector) |
|
122 | |||
123 | /** |
||
124 | * @param string $id |
||
125 | * @param string $class |
||
126 | * @return void |
||
127 | * @throws InvalidArgumentException |
||
128 | */ |
||
129 | 8 | private function bindClass(string $id, string $class) |
|
138 | |||
139 | /** |
||
140 | * @param string $id |
||
141 | * @param object $instance |
||
142 | * @return void |
||
143 | * @throws InvalidArgumentException |
||
144 | */ |
||
145 | 31 | private function bindInstance(string $id, $instance) |
|
154 | |||
155 | /** |
||
156 | * Check if subject service is an object instance. |
||
157 | * |
||
158 | * @param mixed $service |
||
159 | * @return bool |
||
160 | */ |
||
161 | 31 | private function isConcrete($service): bool |
|
165 | |||
166 | /** |
||
167 | * Verifies that provided callable can be called by service container. |
||
168 | * |
||
169 | * @param Invokable $reflectedCallable |
||
170 | * @return bool |
||
171 | */ |
||
172 | 12 | private function isResolvableCallable(Invokable $reflectedCallable): bool |
|
181 | |||
182 | /** |
||
183 | * Registers binding. |
||
184 | * After this method call binding can be resolved by container. |
||
185 | * |
||
186 | * @param string $id |
||
187 | * @param bool $shared |
||
188 | * @param Closure $registrationCallback |
||
189 | * @return void |
||
190 | */ |
||
191 | 31 | private function register(string $id, bool $shared, Closure $registrationCallback) |
|
209 | |||
210 | /** |
||
211 | * Validate service identifier. Throw an Exception in case of invalid value. |
||
212 | * |
||
213 | * @param string $id |
||
214 | * @return void |
||
215 | * @throws InvalidArgumentException |
||
216 | */ |
||
217 | 31 | private function validateId(string $id) |
|
225 | |||
226 | } |