Total Complexity | 6 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | final class InjectionPoints |
||
11 | { |
||
12 | /** |
||
13 | * Injection points |
||
14 | * |
||
15 | * @var array<array{0:string, 1:string, 2:bool}> |
||
16 | */ |
||
17 | private $points = []; |
||
18 | |||
19 | /** |
||
20 | * @param class-string $class |
||
|
|||
21 | * |
||
22 | * @throws ReflectionException |
||
23 | */ |
||
24 | public function __invoke(string $class): SetterMethods |
||
25 | { |
||
26 | $points = []; |
||
27 | foreach ($this->points as $point) { |
||
28 | $points[] = $this->getSetterMethod($class, $point); |
||
29 | } |
||
30 | |||
31 | return new SetterMethods($points); |
||
32 | } |
||
33 | |||
34 | public function addMethod(string $method, string $name = Name::ANY): self |
||
39 | } |
||
40 | |||
41 | public function addOptionalMethod(string $method, string $name = Name::ANY): self |
||
42 | { |
||
43 | $this->points[] = [$method, $name, true]; |
||
44 | |||
45 | return $this; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param class-string $class |
||
50 | * @param array{0: string, 1: string, 2: bool} $point |
||
51 | * |
||
52 | * @throws ReflectionException |
||
53 | */ |
||
54 | private function getSetterMethod(string $class, array $point): SetterMethod |
||
62 | } |
||
63 | } |
||
64 |