| Current Path : /home/smartconb/www/armencom33/acv2026/classes/ |
| Current File : /home/smartconb/www/armencom33/acv2026/classes/UserType.class.php |
<?php
/**
* User: zaven
* Date: 04.06.2018
* Time: 17:44
* Project: cnpa_mail
**/
abstract class BasicEnum
{
private static $constCacheArray = NULL;
public static function isValidName($name, $strict = false)
{
$constants = self::getConstants();
if ($strict) {
return array_key_exists($name, $constants);
}
$keys = array_map('strtolower', array_keys($constants));
return in_array(strtolower($name), $keys);
}
private static function getConstants()
{
if (self::$constCacheArray == NULL) {
self::$constCacheArray = [];
}
$calledClass = get_called_class();
if (!array_key_exists($calledClass, self::$constCacheArray)) {
$reflect = new ReflectionClass($calledClass);
self::$constCacheArray[$calledClass] = $reflect->getConstants();
}
return self::$constCacheArray[$calledClass];
}
public static function isValidValue($value, $strict = true)
{
$values = array_values(self::getConstants());
return in_array($value, $values, $strict);
}
}
abstract class UserType extends BasicEnum
{
const SiteGuest = 1;
const SiteUser = 2;
const SiteSuperUser = 4;
}