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