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-15 13:19:29 -04:00
|
|
|
namespace Aviat\AnimeClient;
|
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-10-09 14:34:55 -04:00
|
|
|
protected $map = [];
|
2015-06-26 12:03:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param array $config_files
|
|
|
|
*/
|
2015-10-09 14:34:55 -04:00
|
|
|
public function __construct(array $config_array = [])
|
2015-06-26 12:03:42 -04:00
|
|
|
{
|
2015-10-09 14:34:55 -04:00
|
|
|
$this->map = $config_array;
|
2015-06-26 12:03:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-06 11:38:20 -04:00
|
|
|
* Get a config value
|
2015-06-26 12:03:42 -04:00
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2015-10-06 11:38:20 -04:00
|
|
|
public function get($key)
|
2015-06-26 12:03:42 -04:00
|
|
|
{
|
2015-10-09 14:34:55 -04:00
|
|
|
if (array_key_exists($key, $this->map))
|
2015-06-26 12:03:42 -04:00
|
|
|
{
|
2015-10-09 14:34:55 -04:00
|
|
|
return $this->map[$key];
|
2015-06-26 12:03:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2015-10-09 14:34:55 -04:00
|
|
|
$this->map[$key] = $value;
|
2015-10-06 11:38:20 -04:00
|
|
|
return $this;
|
|
|
|
}
|
2015-06-26 12:03:42 -04:00
|
|
|
}
|
|
|
|
// End of config.php
|