| Total Complexity | 7 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | trait AccessRestrictedElementTrait |
||
| 10 | { |
||
| 11 | protected string $access; |
||
| 12 | |||
| 13 | 110 | public function setAccess(?string $access): AbstractElement |
|
| 14 | { |
||
| 15 | 110 | if (!static::accessIsValid($access)) { |
|
| 16 | 2 | throw new InvalidArgumentException(sprintf('Access "%s" is invalid, please provide one of these accesses: %s', $access, implode(', ', AccessRestrictedElementInterface::ACCESSES))); |
|
| 17 | } |
||
| 18 | 110 | $this->access = $access; |
|
| 19 | |||
| 20 | 110 | return $this; |
|
|
|
|||
| 21 | } |
||
| 22 | |||
| 23 | 82 | public function getAccess(): string |
|
| 26 | } |
||
| 27 | |||
| 28 | 110 | public static function accessIsValid(?string $access): bool |
|
| 29 | { |
||
| 30 | 110 | return '' === $access || in_array($access, AccessRestrictedElementInterface::ACCESSES, true); |
|
| 31 | } |
||
| 32 | |||
| 33 | 82 | protected function getPhpAccess(): string |
|
| 36 | } |
||
| 37 | } |
||
| 38 |