| Total Complexity | 9 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | abstract class Instantiator implements InstantiatorInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private const CONSTRUCTOR_NAME = '__construct'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var ContextRenderer |
||
| 25 | */ |
||
| 26 | protected $renderer; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param ContextRenderer|null $renderer |
||
| 30 | */ |
||
| 31 | public function __construct(ContextRenderer $renderer = null) |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param \ReflectionClass $class |
||
| 38 | * @return \ReflectionMethod|null |
||
| 39 | */ |
||
| 40 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
||
| 41 | { |
||
| 42 | if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
||
| 43 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($constructor = $this->getTraitConstructors($class)) { |
||
| 47 | return $constructor; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($parent = $class->getParentClass()) { |
||
| 51 | return $this->getConstructor($parent); |
||
| 52 | } |
||
| 53 | |||
| 54 | return null; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param \ReflectionClass $class |
||
| 59 | * @return \ReflectionMethod|null |
||
| 60 | */ |
||
| 61 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
||
| 74 | } |
||
| 75 | } |
||
| 76 |