mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-12-06 11:22:41 +01:00
added resource members
This commit is contained in:
parent
851fa0a1cc
commit
92c431e856
14 changed files with 311 additions and 20 deletions
|
@ -3,12 +3,20 @@
|
|||
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;
|
||||
public static function fromName(string $name) {
|
||||
foreach(self::cases() as $status) {
|
||||
if($name === $status->name){
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
throw new \ValueError("$name is not a valid value for enum " . self::class );
|
||||
}
|
||||
|
||||
public static function fromNameOrValue(int|string $scalar) {
|
||||
if(gettype($scalar) == "integer") {
|
||||
return self::tryFrom($scalar);
|
||||
} else {
|
||||
return self::fromName($scalar);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue