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