1
0
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:
Marco
2018-03-10 01:58:54 +01:00
parent 04edd9f88f
commit 7d44158c32

View File

@@ -41,6 +41,39 @@ final class Role {
// const XXX = 268435456; // const XXX = 268435456;
// const XXX = 536870912; // 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() {} private function __construct() {}
} }