Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class ClassDefinition extends Definition |
||
10 | { |
||
11 | /** @var Attribute[] */ |
||
12 | public $attributes; |
||
13 | |||
14 | /** @var InterfaceDefinition[] */ |
||
15 | public $implements; |
||
16 | |||
17 | 123 | public function __construct( |
|
18 | string $name, |
||
19 | array $attributes = [], |
||
20 | array $functions = [], |
||
21 | array $implements = [], |
||
22 | $extends = null |
||
23 | ) { |
||
24 | 123 | parent::__construct($name, $functions, $extends); |
|
25 | 123 | $this->attributes = $attributes; |
|
26 | 123 | $this->implements = $implements; |
|
27 | 123 | } |
|
28 | |||
29 | public function hasConstructor(): bool |
||
30 | { |
||
31 | 27 | return \count(array_filter($this->functions, function (Method $function) { |
|
32 | 21 | return $function->isConstructor(); |
|
33 | 27 | })) === 1; |
|
34 | } |
||
35 | |||
36 | /** @return Variable[] */ |
||
37 | 15 | public function constructorParameters(): array |
|
38 | { |
||
39 | 15 | if (!$this->hasConstructor()) { |
|
40 | 3 | return []; |
|
41 | } |
||
42 | |||
43 | 12 | $constructors = array_filter($this->functions, function (Method $function) { |
|
44 | 12 | return $function->isConstructor(); |
|
45 | 12 | }); |
|
46 | |||
47 | 12 | return reset($constructors)->params; |
|
48 | } |
||
49 | |||
50 | 30 | public function hasParent(): bool |
|
53 | } |
||
54 | } |
||
55 |