openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit bb9306021e604f25450296a3d7de352df62bc5c7
parent e3dd018d008eab1795e9a338ac0fe3253e7c37ca
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 23 Feb 2020 00:41:36 +0100

Fix: Class extension.

Diffstat:
modules/configuration/Config.class.php | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/configuration/Config.php | 98-------------------------------------------------------------------------------
2 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/modules/configuration/Config.class.php b/modules/configuration/Config.class.php @@ -0,0 +1,97 @@ +<?php + +namespace configuration; + +class Config +{ + private $config = array(); + + + /** + * Config constructor. + * @param $config + */ + public function __construct($config) + { + $this->config = $config; + } + + + /** + * Giving the child configuration with a fluent interface. + * + * @param $name + * @return Config + */ + public function subset($name) + { + if (isset($this->config[$name])) + return new Config($this->config[$name]); + else + return new Config(array()); + } + + + /** + * Gets the configuration value for this key. + * + * @param $name + * @param null $default + * @return mixed|null + */ + public function get($name, $default = null) + { + if (isset($this->config[$name])) { + $value = $this->config[$name]; + + // if default-value is given, the type of the default-value is forced. + if (!is_null($default)) + settype($value, gettype($default)); + return $value; + } else { + return $default; + } + } + + + /** + * Is the Config key present? + * + * @param $name + * @return bool + */ + public function has($name) + { + return isset($this->config[$name]); + } + + + /** + * Is the boolean Value true? + * + * @param $name + * @param bool $default false + * @return bool + */ + public function is($name, $default = false) + { + if (isset($this->config[$name])) + return (bool)$this->config[$name]; + else + return $default; + } + + + /** + * The configuration entries as an array. + * + * @return array + */ + public function getConfig() + { + + return $this->config; + } + + +}+ \ No newline at end of file diff --git a/modules/configuration/Config.php b/modules/configuration/Config.php @@ -1,97 +0,0 @@ -<?php - -namespace configuration; - -class Config -{ - private $config = array(); - - - /** - * Config constructor. - * @param $config - */ - public function __construct($config) - { - $this->config = $config; - } - - - /** - * Giving the child configuration with a fluent interface. - * - * @param $name - * @return Config - */ - public function subset($name) - { - if (isset($this->config[$name])) - return new Config($this->config[$name]); - else - return new Config(array()); - } - - - /** - * Gets the configuration value for this key. - * - * @param $name - * @param null $default - * @return mixed|null - */ - public function get($name, $default = null) - { - if (isset($this->config[$name])) { - $value = $this->config[$name]; - - // if default-value is given, the type of the default-value is forced. - if (!is_null($default)) - settype($value, gettype($default)); - return $value; - } else { - return $default; - } - } - - - /** - * Is the Config key present? - * - * @param $name - * @return bool - */ - public function has($name) - { - return isset($this->config[$name]); - } - - - /** - * Is the boolean Value true? - * - * @param $name - * @param bool $default false - * @return bool - */ - public function is($name, $default = false) - { - if (isset($this->config[$name])) - return (bool)$this->config[$name]; - else - return $default; - } - - - /** - * The configuration entries as an array. - * - * @return array - */ - public function getConfig() - { - - return $this->config; - } - - -}- \ No newline at end of file