0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-22 04:38:09 +01:00

added resource member enums

This commit is contained in:
Jonathan Treffler 2024-10-30 04:40:09 +01:00
parent 2daa036a53
commit 51a29a3844
3 changed files with 35 additions and 0 deletions

14
lib/Enum/FromNameEnum.php Normal file
View 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 );
}
}

View 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
View file

@ -0,0 +1,11 @@
<?php
namespace OCA\OrganizationFolders\Enum;
enum MemberType: int {
use FromNameEnum;
case USER = 1;
case GROUP = 2;
case ROLE = 3;
}