Total Complexity | 7 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | final class AnnotatedClass |
||
12 | { |
||
13 | /** @var AnnotatedClassMethods */ |
||
14 | private $injectionMethod; |
||
15 | |||
16 | public function __construct() |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Return factory instance |
||
23 | * |
||
24 | * @phpstan-param ReflectionClass<object> $class Target class reflection |
||
25 | */ |
||
26 | public function getNewInstance(ReflectionClass $class): NewInstance |
||
27 | { |
||
28 | $setterMethods = new SetterMethods([]); |
||
29 | $methods = $class->getMethods(); |
||
30 | foreach ($methods as $method) { |
||
31 | if ($method->name === '__construct') { |
||
32 | continue; |
||
33 | } |
||
34 | |||
35 | $setterMethods->add($this->injectionMethod->getSetterMethod($method)); |
||
36 | } |
||
37 | |||
38 | $name = $this->injectionMethod->getConstructorName($class); |
||
39 | |||
40 | return new NewInstance($class, $setterMethods, $name); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Return @-PostConstruct method reflection |
||
45 | * |
||
46 | * @phpstan-param ReflectionClass<object> $class |
||
47 | */ |
||
48 | public function getPostConstruct(ReflectionClass $class): ?ReflectionMethod |
||
59 | } |
||
60 | } |
||
61 |