Total Complexity | 8 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | abstract class AbstractDefinition |
||
16 | { |
||
17 | /** |
||
18 | * @var ReflectionMethod |
||
19 | */ |
||
20 | protected $reflectionMethod; |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $name; |
||
25 | /** |
||
26 | * @var Tag[] |
||
27 | */ |
||
28 | protected $tags = []; |
||
29 | |||
30 | public function __construct(ReflectionMethod $reflectionMethod) |
||
31 | { |
||
32 | $this->reflectionMethod = $reflectionMethod; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Returns a list of services to be injected. |
||
37 | * |
||
38 | * @return Injection |
||
39 | */ |
||
40 | protected function mapParameterToInjection(ReflectionParameter $reflectionParameter): Injection |
||
41 | { |
||
42 | $type = $reflectionParameter->getType(); |
||
43 | // No type? Let's inject by parameter name. |
||
44 | if ($type === null || $type->isBuiltin()) { |
||
45 | return new ServiceInjection($reflectionParameter->getName(), !$reflectionParameter->allowsNull()); |
||
46 | } |
||
47 | if (((string)$type) === ContainerInterface::class) { |
||
48 | return new ContainerInjection(); |
||
49 | } |
||
50 | return new ServiceInjection((string)$type, !$reflectionParameter->allowsNull()); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return ReflectionMethod |
||
55 | */ |
||
56 | public function getReflectionMethod(): ReflectionMethod |
||
57 | { |
||
58 | return $this->reflectionMethod; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getName(): string |
||
65 | { |
||
66 | return $this->name; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return Tag[] |
||
71 | */ |
||
72 | public function getTags(): array |
||
75 | } |
||
76 | } |
||
77 |