Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
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 | public function __construct( |
||
18 | string $name, |
||
19 | array $attributes = [], |
||
20 | array $functions = [], |
||
21 | array $implements = [], |
||
22 | $extends = null |
||
23 | ) { |
||
24 | parent::__construct($name, $functions, $extends); |
||
25 | $this->attributes = $attributes; |
||
26 | $this->implements = $implements; |
||
27 | } |
||
28 | |||
29 | public function hasConstructor(): bool |
||
30 | { |
||
31 | return \count(array_filter($this->functions, function (Method $function) { |
||
32 | return $function->isConstructor(); |
||
33 | })) === 1; |
||
34 | } |
||
35 | |||
36 | /** @return Variable[] */ |
||
37 | public function constructorParameters(): array |
||
38 | { |
||
39 | if (!$this->hasConstructor()) { |
||
40 | return []; |
||
41 | } |
||
42 | |||
43 | $constructors = array_filter($this->functions, function (Method $function) { |
||
44 | return $function->isConstructor(); |
||
45 | }); |
||
46 | |||
47 | return reset($constructors)->params; |
||
48 | } |
||
49 | |||
50 | public function hasParent(): bool |
||
53 | } |
||
54 | } |
||
55 |