1 | <?php declare(strict_types=1); |
||
15 | class Container implements ContainerInterface |
||
16 | { |
||
17 | /** @var array[string] Collection of loaded services */ |
||
18 | protected $services = []; |
||
19 | |||
20 | /** @var array[string] Collection of alias => class name for alias resolving */ |
||
21 | protected $aliases = []; |
||
22 | |||
23 | /** @var array[string] Collection of class name dependencies trees */ |
||
24 | protected $dependencies = []; |
||
25 | |||
26 | /** @var ContainerInterface[] Collection of delegated containers */ |
||
27 | protected $delegates = []; |
||
28 | |||
29 | /** @var callable Dependency resolving function callable */ |
||
30 | protected $logicCallable; |
||
31 | |||
32 | |||
33 | /** |
||
34 | * Wrapper for calling dependency resolving function. |
||
35 | * |
||
36 | * @param string $dependency Dependency name |
||
37 | * |
||
38 | * @return mixed Created instance or null |
||
39 | * @throws ContainerException |
||
40 | */ |
||
41 | 1 | protected function logic($dependency) |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | * |
||
53 | * @throws \samsonframework\di\exception\ContainerException |
||
54 | */ |
||
55 | 1 | public function get($dependency) |
|
79 | |||
80 | /** |
||
81 | * Implementing delegate lookup feature. |
||
82 | * If current container cannot resolve entity dependency |
||
83 | * resolving process is passed to delegated container. |
||
84 | * |
||
85 | * @param ContainerInterface $container Container for delegate lookup |
||
86 | */ |
||
87 | public function delegate(ContainerInterface $container) |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function has($dependency) : bool |
||
110 | |||
111 | /** |
||
112 | * Set service dependency. Upon first creation of this class instance |
||
113 | * it would be used everywhere where this dependency is needed. |
||
114 | * |
||
115 | * @param string $className Fully qualified class name |
||
116 | * @param array $parameters Collection of parameters needed for dependency creation |
||
117 | * @param string $alias Dependency name |
||
118 | * |
||
119 | * @return ContainerInterface Chaining |
||
120 | */ |
||
121 | 3 | public function service($className, array $parameters = [], string $alias = null) : ContainerInterface |
|
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | 3 | public function set($className, array $dependencies = [], string $alias = null) : ContainerInterface |
|
146 | } |
||
147 |