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 | * @inheritDoc |
||
45 | */ |
||
46 | 10 | public function bind(string $id, $service) |
|
56 | |||
57 | /** |
||
58 | * @inheritDoc |
||
59 | */ |
||
60 | 4 | public function decorate(string $id, $decorator) |
|
71 | |||
72 | /** |
||
73 | * @inheritDoc |
||
74 | */ |
||
75 | 12 | public function factory(string $id, $callable, $shared = false) |
|
86 | |||
87 | /** |
||
88 | * @inheritDoc |
||
89 | */ |
||
90 | 4 | public function inflect(string $id, string $method, array $arguments = []) |
|
94 | |||
95 | /** |
||
96 | * @inheritDoc |
||
97 | */ |
||
98 | 27 | protected function instantiateService(string $id, array $arguments) |
|
105 | |||
106 | /** |
||
107 | * @param ServiceDecoratorContract $decorator |
||
108 | */ |
||
109 | 31 | protected function setDecorator(ServiceDecoratorContract $decorator) |
|
113 | |||
114 | /** |
||
115 | * @param ServiceInflectorContract $inflector |
||
116 | */ |
||
117 | 31 | protected function setInflector(ServiceInflectorContract $inflector) |
|
121 | |||
122 | /** |
||
123 | * @param string $id |
||
124 | * @param string $class |
||
125 | * @return void |
||
126 | * @throws InvalidArgumentException |
||
127 | */ |
||
128 | 8 | private function bindClass(string $id, string $class) |
|
137 | |||
138 | /** |
||
139 | * @param string $id |
||
140 | * @param object $instance |
||
141 | * @return void |
||
142 | * @throws InvalidArgumentException |
||
143 | */ |
||
144 | 31 | private function bindInstance(string $id, $instance) |
|
153 | |||
154 | /** |
||
155 | * Check if subject service is an object instance. |
||
156 | * |
||
157 | * @param mixed $service |
||
158 | * @return bool |
||
159 | */ |
||
160 | 31 | private function isConcrete($service): bool |
|
164 | |||
165 | /** |
||
166 | * Verifies that provided callable can be called by service container. |
||
167 | * |
||
168 | * @param Invokable $reflectedCallable |
||
169 | * @return bool |
||
170 | */ |
||
171 | 12 | private function isResolvableCallable(Invokable $reflectedCallable): bool |
|
180 | |||
181 | /** |
||
182 | * Registers binding. |
||
183 | * After this method call binding can be resolved by container. |
||
184 | * |
||
185 | * @param string $id |
||
186 | * @param bool $shared |
||
187 | * @param Closure $registrationCallback |
||
188 | * @return void |
||
189 | */ |
||
190 | 31 | private function register(string $id, bool $shared, Closure $registrationCallback) |
|
208 | |||
209 | /** |
||
210 | * Validate service identifier. Throw an Exception in case of invalid value. |
||
211 | * |
||
212 | * @param string $id |
||
213 | * @return void |
||
214 | * @throws InvalidArgumentException |
||
215 | */ |
||
216 | 31 | private function validateId(string $id) |
|
224 | |||
225 | } |