0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-25 14:10:26 +01:00
organization_folders/lib/Enum/FromNameEnum.php

14 lines
373 B
PHP
Raw Normal View History

2024-10-30 04:40:09 +01:00
<?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 );
}
}