| Total Complexity | 8 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | abstract class Instantiator implements InstantiatorInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private const CONSTRUCTOR_NAME = '__construct'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param \ReflectionClass $class |
||
| 23 | * @return \ReflectionMethod|null |
||
| 24 | */ |
||
| 25 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
||
| 26 | { |
||
| 27 | if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
||
| 28 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($constructor = $this->getTraitConstructors($class)) { |
||
| 32 | return $constructor; |
||
| 33 | } |
||
| 34 | |||
| 35 | if ($parent = $class->getParentClass()) { |
||
| 36 | return $this->getConstructor($parent); |
||
| 37 | } |
||
| 38 | |||
| 39 | return null; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param \ReflectionClass $class |
||
| 44 | * @return \ReflectionMethod|null |
||
| 45 | */ |
||
| 46 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
||
| 59 | } |
||
| 60 | } |