/** * @return array */ static function getValues() { if (null === static::$constants) { static::$constants = (new \ReflectionClass(get_called_class()))->getConstants(); } return static::$constants; }
public function __construct($config) { if (!isset(static::$constants)) { static::$constants = (new ReflectionClass(get_called_class()))->getConstants(); } if (!in_array($config, array_values(static::$constants))) { throw new UnknownDnsConfigurationException("Unknown DNS Configuration [{$config}]"); } $this->config = $config; }
function __construct($appPurpose) { if (!isset(static::$constants)) { static::$constants = (new ReflectionClass(get_called_class()))->getConstants(); } if (!in_array($appPurpose, array_values(static::$constants))) { throw new UnknownAppPurposeException("Unknown app purpose [{$appPurpose}]"); } $this->appPurpose = $appPurpose; }
function __construct($nexusCategory) { if (!isset(static::$constants)) { static::$constants = (new ReflectionClass(get_called_class()))->getConstants(); } if (!in_array($nexusCategory, array_values(static::$constants))) { throw new UnknownNexusCategoryException("Unknown nexus category [{$nexusCategory}]"); } $this->nexusCategory = $nexusCategory; }
/** * Clears up the registered meta tags, link tags, css/js scripts and files. */ public function clear() { $this->metaTags = []; $this->linkTags = []; $this->css = []; $this->cssFiles = []; $this->js = []; $this->jsFiles = []; static::$constants = []; $this->placeholders = []; }
/** * Class constructor * * @param object $constants * @param object $cooker * @param object $injector * @param object $crypt * @param object $databaseService * @param object $repository * @param object $eventDispatcher * */ public function __construct(Constants $constants, CookerInterface $cooker, Injector $injector, CryptInterface $crypt, DatabaseServiceInterface $databaseService, SessionHandlerInterface $repository, Dispatcher $eventDispatcher) { static::$constants = $constants; static::$injector = $injector; static::$repository = $repository; static::$cooker = $cooker; static::$eventDispatcher = $eventDispatcher; static::$crypt = $crypt; static::$eventDispatcher->setInstance(static::getInstance()); static::$model = $databaseService->get(static::$injector->get('db')); static::$env = php_sapi_name(); static::setSession(static::$repository); }
/** * Set the Glad\Constants class instance * * @return void */ protected static function setConstantsInstance() { if (!is_object(static::$constants)) { static::$constants = static::getConstantsInstance(); static::$injector->resolve(static::$constants); } }
/** * This method is used to retrieve the first constant-name in a class that matches the value provided. * * @access public * @static * @param string $name the name of the constant to return * @return integer the value of the named constant * * @see http://stackoverflow.com/questions/1880148/how-to-get-name-of-the-constant */ public static function valueOf($name) { if (static::$constants === null) { $class = new \ReflectionClass(__CLASS__); static::$constants = new Common\HashMap($class->getConstants()); } return static::$constants->getValue($name); }