Total Complexity | 7 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
26 | class RolesService implements RolesServiceInterface |
||
27 | { |
||
28 | 718 | public function __construct( |
|
29 | private readonly RoleHierarchyInterface $roleHierarchy, |
||
30 | ) { |
||
31 | 718 | } |
|
32 | |||
33 | 13 | public function getRoles(): array |
|
34 | { |
||
35 | 13 | return array_map(static fn (BackedEnum $enum): string => $enum->value, Role::cases()); |
|
|
|||
36 | } |
||
37 | |||
38 | 18 | public function getRoleLabel(string $role): string |
|
39 | { |
||
40 | 18 | $enum = Role::tryFrom($role); |
|
41 | |||
42 | 18 | return $enum instanceof Role |
|
43 | 17 | ? $enum->label() |
|
44 | 18 | : 'Unknown - ' . $role; |
|
45 | } |
||
46 | |||
47 | 18 | public function getShort(string $role): string |
|
48 | { |
||
49 | 18 | $enum = Role::tryFrom($role); |
|
50 | |||
51 | 18 | return $enum instanceof Role |
|
52 | 17 | ? mb_strtolower($enum->name) |
|
53 | 18 | : 'Unknown - ' . $role; |
|
54 | } |
||
55 | |||
56 | 286 | public function getInheritedRoles(array $roles): array |
|
59 | } |
||
60 | } |
||
61 |