mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-22 12:40:28 +01:00
14 lines
373 B
PHP
14 lines
373 B
PHP
|
<?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 );
|
||
|
}
|
||
|
}
|