2015-06-26 12:03:42 -04:00
|
|
|
<?php
|
2015-09-14 10:54:50 -04:00
|
|
|
/**
|
|
|
|
* Base Configuration class
|
|
|
|
*/
|
2015-06-26 12:03:42 -04:00
|
|
|
|
2015-09-14 19:54:34 -04:00
|
|
|
namespace Aviat\AnimeClient\Base;
|
2015-06-26 16:39:10 -04:00
|
|
|
|
2015-06-26 12:03:42 -04:00
|
|
|
/**
|
|
|
|
* Wrapper for configuration values
|
|
|
|
*/
|
|
|
|
class Config {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Config object
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-06-29 09:46:49 -04:00
|
|
|
protected $config = [];
|
2015-06-26 12:03:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param array $config_files
|
|
|
|
*/
|
|
|
|
public function __construct(Array $config_files=[])
|
|
|
|
{
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
if (empty($config_files))
|
|
|
|
{
|
2015-09-14 10:54:50 -04:00
|
|
|
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 12:03:42 -04:00
|
|
|
}
|
2015-06-26 16:39:10 -04:00
|
|
|
else // @codeCoverageIgnoreEnd
|
2015-06-26 12:03:42 -04:00
|
|
|
{
|
2015-09-14 10:54:50 -04:00
|
|
|
$this->config = $config_files;
|
2015-06-26 12:03:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Getter for config values
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function __get($key)
|
|
|
|
{
|
|
|
|
if (isset($this->config[$key]))
|
|
|
|
{
|
|
|
|
return $this->config[$key];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// End of config.php
|