Total Complexity | 6 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class Attribute extends Variable implements HasVisibility, CanBeStatic |
||
14 | { |
||
15 | use WithVisibility, WithStaticModifier; |
||
16 | |||
17 | 96 | protected function __construct(string $name, Visibility $modifier, TypeDeclaration $type) |
|
18 | { |
||
19 | 96 | parent::__construct($name, $type); |
|
20 | 96 | $this->modifier = $modifier; |
|
21 | 96 | $this->isStatic = false; |
|
22 | 96 | } |
|
23 | |||
24 | 60 | public static function public(string $name, TypeDeclaration $type = null): Attribute |
|
25 | { |
||
26 | 60 | return new static($name, Visibility::public(), $type ?? TypeDeclaration::absent()); |
|
27 | } |
||
28 | |||
29 | 48 | public static function protected(string $name, TypeDeclaration $type = null): Attribute |
|
32 | } |
||
33 | |||
34 | 72 | public static function private(string $name, TypeDeclaration $type = null): Attribute |
|
35 | { |
||
36 | 72 | return new static($name, Visibility::private(), $type ?? TypeDeclaration::absent()); |
|
37 | } |
||
38 | |||
39 | 42 | public function __toString() |
|
45 | ); |
||
46 | } |
||
47 | } |
||
48 |