1 | <?php declare(strict_types=1); |
||
12 | class Definition implements ArgumentResolverInterface, DefinitionInterface |
||
13 | { |
||
14 | use ArgumentResolverTrait; |
||
15 | use ContainerAwareTrait; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $alias; |
||
21 | |||
22 | /** |
||
23 | * @var mixed |
||
24 | */ |
||
25 | protected $concrete; |
||
26 | |||
27 | /** |
||
28 | * @var boolean |
||
29 | */ |
||
30 | protected $shared = false; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $tags = []; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $arguments = []; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $methods = []; |
||
46 | |||
47 | /** |
||
48 | * @var mixed |
||
49 | */ |
||
50 | protected $resolved; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * |
||
55 | * @param string $id |
||
56 | * @param mixed $concrete |
||
57 | */ |
||
58 | 69 | public function __construct(string $id, $concrete = null) |
|
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | 6 | public function addTag(string $tag) : DefinitionInterface |
|
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | 6 | public function hasTag(string $tag) : bool |
|
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 36 | public function setAlias(string $id) : DefinitionInterface |
|
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 33 | public function getAlias() : string |
|
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | 39 | public function setShared(bool $shared = true) : DefinitionInterface |
|
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | 45 | public function isShared() : bool |
|
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | 6 | public function getConcrete() |
|
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | 3 | public function setConcrete($concrete) : DefinitionInterface |
|
138 | |||
139 | /** |
||
140 | * {@inheritdoc} |
||
141 | */ |
||
142 | 15 | public function addArgument($arg) : DefinitionInterface |
|
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | 3 | public function addArguments(array $args) : DefinitionInterface |
|
160 | |||
161 | /** |
||
162 | * {@inheritdoc} |
||
163 | */ |
||
164 | 3 | public function addMethodCall(string $method, array $args = []) : DefinitionInterface |
|
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | 3 | public function addMethodCalls(array $methods = []) : DefinitionInterface |
|
185 | |||
186 | /** |
||
187 | * {@inheritdoc} |
||
188 | */ |
||
189 | 45 | public function resolve(bool $new = false) |
|
227 | |||
228 | /** |
||
229 | * Resolve a callable. |
||
230 | * |
||
231 | 12 | * @param callable $concrete |
|
232 | * |
||
233 | 12 | * @return mixed |
|
234 | */ |
||
235 | 12 | protected function resolveCallable(callable $concrete) |
|
241 | |||
242 | /** |
||
243 | * Resolve a class. |
||
244 | * |
||
245 | * @param string $concrete |
||
246 | * |
||
247 | 33 | * @return object |
|
248 | * |
||
249 | 33 | * @throws ReflectionException |
|
250 | 33 | */ |
|
251 | protected function resolveClass(string $concrete) |
||
258 | |||
259 | /** |
||
260 | * Invoke methods on resolved instance. |
||
261 | * |
||
262 | 39 | * @param object $instance |
|
263 | * |
||
264 | 39 | * @return object |
|
265 | 3 | */ |
|
266 | protected function invokeMethods($instance) |
||
278 | } |
||
279 |