mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 07:37:25 +02:00
Implement methods 'getMap', 'getNames' and 'getValues' in class 'Role'
This commit is contained in:
33
src/Role.php
33
src/Role.php
@@ -41,6 +41,39 @@ final class Role {
|
||||
// const XXX = 268435456;
|
||||
// const XXX = 536870912;
|
||||
|
||||
/**
|
||||
* Returns an array mapping the numerical role values to their descriptive names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getMap() {
|
||||
$reflectionClass = new \ReflectionClass(static::class);
|
||||
|
||||
return \array_flip($reflectionClass->getConstants());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptive role names
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getNames() {
|
||||
$reflectionClass = new \ReflectionClass(static::class);
|
||||
|
||||
return \array_keys($reflectionClass->getConstants());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numerical role values
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public static function getValues() {
|
||||
$reflectionClass = new \ReflectionClass(static::class);
|
||||
|
||||
return \array_values($reflectionClass->getConstants());
|
||||
}
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user