HummingBirdAnimeClient/src/Aviat/AnimeClient/Config.php

70 lines
1.0 KiB
PHP
Raw Normal View History

<?php
/**
* Base Configuration class
*/
2015-09-15 13:19:29 -04:00
namespace Aviat\AnimeClient;
2015-06-26 16:39:10 -04:00
/**
* Wrapper for configuration values
*/
class Config {
/**
* Config object
*
* @var array
*/
2015-06-29 09:46:49 -04:00
protected $config = [];
/**
* Constructor
*
* @param array $config_files
*/
public function __construct(array $config_files = [])
{
// @codeCoverageIgnoreStart
if (empty($config_files))
{
require_once \_dir(CONF_DIR, 'config.php'); // $config
require_once \_dir(CONF_DIR, 'base_config.php'); // $base_config
$this->config = array_merge($config, $base_config);
}
2015-06-26 16:39:10 -04:00
else // @codeCoverageIgnoreEnd
{
$this->config = $config_files;
}
}
/**
2015-10-06 11:38:20 -04:00
* Get a config value
*
* @param string $key
* @return mixed
*/
2015-10-06 11:38:20 -04:00
public function get($key)
{
if (isset($this->config[$key]))
{
return $this->config[$key];
}
return NULL;
}
2015-10-06 11:38:20 -04:00
/**
* Set a config value
*
* @param string $key
* @param mixed $value
* @return Config
*/
public function set($key, $value)
{
$this->config[$key] = $value;
return $this;
}
}
// End of config.php