diff --git a/src/Configuration.php b/src/Configuration.php deleted file mode 100644 index 1520d99..0000000 --- a/src/Configuration.php +++ /dev/null @@ -1,73 +0,0 @@ -values['session']['save_path'] = session_save_path(); - - if(!file_exists($this->custom_config_filename)) { - throw new \RuntimeException('No configuration.local.php file was found. Create it with the proper config.'); - } - - $configuration = include_once realpath(dirname(__FILE__) . '/../config/') . $this->custom_config_filename; - - if(!is_array($configuration)) { - throw new \RuntimeException("You custom configuration in '{$this->custom_config_filename}' must be in a variable named '\$configuration' and be an array."); - } - - $this->values = array_replace_recursive($this->values, $configuration); - } - - private function dotNotationAccess($data, $key, $default=null) - { - $keys = explode('.', $key); - foreach ($keys as $k) { - if (!is_array($data)) { - throw new \Exception("Try to access non-array as array, key '$key''"); - } - if (!isset($data[$k])) { - return $default; - } - - $data = $data[$k]; - } - return $data; - } - - private function value($name, $default) { - return $this->dotNotationAccess($this->values, $name, $default); - } - - /** - * @param $name - * @param mixed $default the default value for your configuration option - * @return mixed return the configuration value if the key is find, the default otherwise - */ - public static function get($name, $default = null) { - if(is_null(self::$instance)) { - self::$instance = new Configuration(); - } - - return self::$instance->value($name, $default); - } -}