mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-05-12 01:15:29 +02:00
38 lines
685 B
PHP
38 lines
685 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;
|
|
}
|
|
}
|