1 | <?php declare(strict_types=1); |
||
11 | class Container implements ContainerInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var boolean |
||
15 | */ |
||
16 | protected $defaultToShared = false; |
||
17 | |||
18 | /** |
||
19 | * @var \League\Container\Definition\DefinitionAggregateInterface |
||
20 | */ |
||
21 | protected $definitions; |
||
22 | |||
23 | /** |
||
24 | * @var \League\Container\ServiceProvider\ServiceProviderAggregateInterface |
||
25 | */ |
||
26 | protected $providers; |
||
27 | |||
28 | /** |
||
29 | * @var \League\Container\Inflector\InflectorAggregateInterface |
||
30 | */ |
||
31 | protected $inflectors; |
||
32 | |||
33 | /** |
||
34 | * @var \Psr\Container\ContainerInterface[] |
||
35 | */ |
||
36 | protected $delegates = []; |
||
37 | |||
38 | /** |
||
39 | * Construct. |
||
40 | * |
||
41 | * @param \League\Container\Definition\DefinitionAggregateInterface|null $definitions |
||
42 | * @param \League\Container\ServiceProvider\ServiceProviderAggregateInterface|null $providers |
||
43 | * @param \League\Container\Inflector\InflectorAggregateInterface|null $inflectors |
||
44 | */ |
||
45 | 45 | public function __construct( |
|
66 | |||
67 | /** |
||
68 | * Add an item to the container. |
||
69 | * |
||
70 | * @param string $id |
||
71 | * @param mixed $concrete |
||
72 | * @param boolean $shared |
||
73 | * |
||
74 | * @return \League\Container\Definition\DefinitionInterface |
||
75 | */ |
||
76 | 24 | public function add(string $id, $concrete = null, bool $shared = false) : DefinitionInterface |
|
83 | |||
84 | /** |
||
85 | * Proxy to add with shared as true. |
||
86 | * |
||
87 | * @param string $id |
||
88 | * @param mixed $concrete |
||
89 | * |
||
90 | * @return \League\Container\Definition\DefinitionInterface |
||
91 | */ |
||
92 | 6 | public function share(string $id, $concrete = null) : DefinitionInterface |
|
96 | |||
97 | /** |
||
98 | * Whether the container should default to defining shared definitions. |
||
99 | * |
||
100 | * @param boolean $shared |
||
101 | * |
||
102 | * @return self |
||
103 | */ |
||
104 | 3 | public function defaultToShared(bool $shared = true) : ContainerInterface |
|
110 | |||
111 | /** |
||
112 | * Get a definition to extend. |
||
113 | * |
||
114 | * @param string $id [description] |
||
115 | * |
||
116 | * @return \League\Container\Definition\DefinitionInterface |
||
117 | */ |
||
118 | 9 | public function extend(string $id) : DefinitionInterface |
|
132 | |||
133 | /** |
||
134 | * Add a service provider. |
||
135 | * |
||
136 | * @param \League\Container\ServiceProvider\ServiceProviderInterface|string $provider |
||
137 | * |
||
138 | * @return self |
||
139 | */ |
||
140 | 6 | public function addServiceProvider($provider) : self |
|
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | 24 | public function get($id, bool $new = false) |
|
181 | |||
182 | /** |
||
183 | * {@inheritdoc} |
||
184 | */ |
||
185 | 27 | public function has($id) : bool |
|
207 | |||
208 | /** |
||
209 | * Allows for manipulation of specific types on resolution. |
||
210 | * |
||
211 | * @param string $type |
||
212 | * @param callable|null $callback |
||
213 | * |
||
214 | * @return \League\Container\Inflector\InflectorInterface |
||
215 | */ |
||
216 | 3 | public function inflector(string $type, callable $callback = null) : InflectorInterface |
|
220 | |||
221 | /** |
||
222 | * Delegate a backup container to be checked for services if it |
||
223 | * cannot be resolved via this container. |
||
224 | * |
||
225 | * @param \Psr\Container\ContainerInterface $container |
||
226 | * |
||
227 | * @return self |
||
228 | */ |
||
229 | 3 | public function delegate(ContainerInterface $container) : self |
|
239 | } |
||
240 |