mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-21 20:28:11 +01:00
added resource member enums
This commit is contained in:
parent
2daa036a53
commit
51a29a3844
3 changed files with 35 additions and 0 deletions
14
lib/Enum/FromNameEnum.php
Normal file
14
lib/Enum/FromNameEnum.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Enum;
|
||||
|
||||
trait FromNameEnum {
|
||||
public static function fromName(string $name): string {
|
||||
foreach (self::cases() as $status) {
|
||||
if( $name === $status->name ){
|
||||
return $status->value;
|
||||
}
|
||||
}
|
||||
throw new \ValueError("$name is not a valid value for enum " . self::class );
|
||||
}
|
||||
}
|
10
lib/Enum/MemberPermissionLevel.php
Normal file
10
lib/Enum/MemberPermissionLevel.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Enum;
|
||||
|
||||
enum MemberPermissionLevel: int {
|
||||
use FromNameEnum;
|
||||
|
||||
case MEMBER = 1;
|
||||
case MANAGER = 2;
|
||||
}
|
11
lib/Enum/MemberType.php
Normal file
11
lib/Enum/MemberType.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Enum;
|
||||
|
||||
enum MemberType: int {
|
||||
use FromNameEnum;
|
||||
|
||||
case USER = 1;
|
||||
case GROUP = 2;
|
||||
case ROLE = 3;
|
||||
}
|
Loading…
Reference in a new issue