Open
Description
/**
* Gets the key of the provided value.
*
* @param string $value The value.
*
* **@return boolean The key if found, false otherwise.**
*/
public static function getKey($value)
{
return array_search($value, static::getAll(), true);
}
array_search will return the element, if found, which would be a string
...
class UserRoles extends AbstractEnum
{
const ADMIN = 1;
const MODERATOR = 2;
const CLIENT = 3;
const WRITER = 4;
}
UserRoles::getKey(3)
will return 'client'
Metadata
Metadata
Assignees
Labels
No labels