Ecodev /
felix
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ecodev\Felix\Acl; |
||
| 6 | |||
| 7 | use Exception; |
||
| 8 | use Laminas\Permissions\Acl\Role\RoleInterface; |
||
| 9 | use Stringable; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * A role containing multiple roles. |
||
| 13 | */ |
||
| 14 | class MultipleRoles implements RoleInterface, Stringable |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string[] |
||
| 18 | */ |
||
| 19 | private array $roles = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string[] $roles |
||
| 23 | */ |
||
| 24 | 5 | public function __construct(array $roles = []) |
|
| 25 | { |
||
| 26 | 5 | foreach ($roles as $role) { |
|
| 27 | 4 | $this->addRole($role); |
|
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Add a role to the list. |
||
| 33 | */ |
||
| 34 | 4 | public function addRole(string $role): void |
|
| 35 | { |
||
| 36 | 4 | $this->roles[] = $role; |
|
| 37 | |||
| 38 | 4 | $this->roles = array_unique($this->roles); |
|
| 39 | 4 | sort($this->roles); |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function getRoleId(): never |
|
|
1 ignored issue
–
show
|
|||
| 43 | { |
||
| 44 | 1 | throw new Exception('This should never be called. If it is, then it means this class is not used correctly'); |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Return the role list. |
||
| 49 | * |
||
| 50 | * @return string[] |
||
| 51 | */ |
||
| 52 | 4 | public function getRoles(): array |
|
| 53 | { |
||
| 54 | 4 | return $this->roles; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Return whether the given role is included in the list. |
||
| 59 | */ |
||
| 60 | 1 | public function has(string $role): bool |
|
| 61 | { |
||
| 62 | 1 | return in_array($role, $this->roles, true); |
|
| 63 | } |
||
| 64 | |||
| 65 | 2 | public function __toString(): string |
|
| 66 | { |
||
| 67 | 2 | return '[' . implode(', ', $this->roles) . ']'; |
|
| 68 | } |
||
| 69 | } |
||
| 70 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths