Total Complexity | 6 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | trait AccessTrait |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $access = AbstractDeclaration::ACCESS_PRIVATE; |
||
26 | |||
27 | /** |
||
28 | * @param string $access |
||
29 | * |
||
30 | * @return $this |
||
31 | * @throws ReactorException |
||
32 | */ |
||
33 | public function setAccess(string $access): self |
||
34 | { |
||
35 | if ( |
||
36 | !in_array($access, [ |
||
37 | AbstractDeclaration::ACCESS_PRIVATE, |
||
38 | AbstractDeclaration::ACCESS_PROTECTED, |
||
39 | AbstractDeclaration::ACCESS_PUBLIC |
||
40 | ], true) |
||
41 | ) { |
||
42 | throw new ReactorException("Invalid declaration level '{$access}'"); |
||
43 | } |
||
44 | |||
45 | $this->access = $access; |
||
46 | |||
47 | return $this; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | public function getAccess(): string |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return $this |
||
60 | */ |
||
61 | public function setPublic(): self |
||
62 | { |
||
63 | $this->setAccess(AbstractDeclaration::ACCESS_PUBLIC); |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function setProtected(): self |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function setPrivate(): self |
||
88 |