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 | 8 | public function bindClass(string $id, string $class, $shared = false) |
|
76 | |||
77 | /** |
||
78 | * @inheritDoc |
||
79 | */ |
||
80 | 12 | public function bindFactory(string $id, $callable, $shared = false) |
|
91 | |||
92 | /** |
||
93 | * @inheritDoc |
||
94 | */ |
||
95 | 4 | public function bindInstance(string $id, $instance) |
|
104 | |||
105 | /** |
||
106 | * @inheritDoc |
||
107 | */ |
||
108 | 34 | protected function instantiateService(string $id, array $arguments) |
|
115 | |||
116 | /** |
||
117 | * @param ServiceDecoratorContract $decorator |
||
118 | */ |
||
119 | 44 | protected function setDecorator(ServiceDecoratorContract $decorator) |
|
123 | |||
124 | /** |
||
125 | * @param ServiceInflectorContract $inflector |
||
126 | */ |
||
127 | 44 | protected function setInflector(ServiceInflectorContract $inflector) |
|
131 | |||
132 | /** |
||
133 | * Check if subject service is an object instance. |
||
134 | * |
||
135 | * @param mixed $service |
||
136 | * @return bool |
||
137 | */ |
||
138 | 4 | private function isConcrete($service): bool |
|
142 | |||
143 | /** |
||
144 | * Verifies that provided callable can be called by service container. |
||
145 | * |
||
146 | * @param Invokable $reflectedCallable |
||
147 | * @return bool |
||
148 | */ |
||
149 | 12 | private function isResolvableCallable(Invokable $reflectedCallable): bool |
|
158 | |||
159 | /** |
||
160 | * Registers binding. |
||
161 | * After this method call binding can be resolved by container. |
||
162 | * |
||
163 | * @param string $id |
||
164 | * @param bool $shared |
||
165 | * @param Closure $registrationCallback |
||
166 | * @return void |
||
167 | */ |
||
168 | 23 | private function register(string $id, bool $shared, Closure $registrationCallback) |
|
186 | |||
187 | /** |
||
188 | * Validate service identifier. Throw an Exception in case of invalid value. |
||
189 | * |
||
190 | * @param string $id |
||
191 | * @return void |
||
192 | * @throws InvalidArgumentException |
||
193 | */ |
||
194 | 23 | private function validateId(string $id) |
|
202 | |||
203 | |||
204 | } |