mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
40 lines
707 B
PHP
40 lines
707 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\DependencyInjection;
|
|
|
|
/**
|
|
* class ArrayConfig.
|
|
*
|
|
* uses array as data source
|
|
*/
|
|
class ArrayConfig extends AbstractConfig implements Parameters
|
|
{
|
|
/**
|
|
* Get parameter.
|
|
*
|
|
* @param string|int $key
|
|
* @param null $default
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get($key, $default = null)
|
|
{
|
|
if (isset($this->storage[$key])) {
|
|
return $this->storage[$key];
|
|
}
|
|
|
|
return $default;
|
|
}
|
|
|
|
/**
|
|
* Set parameter.
|
|
*
|
|
* @param string|int $key
|
|
* @param mixed $value
|
|
*/
|
|
public function set($key, $value)
|
|
{
|
|
$this->storage[$key] = $value;
|
|
}
|
|
}
|