mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
Implement InversionOfControl aware DependencyInjection
This commit is contained in:
committed by
Dominik Liebler
parent
3114cf1013
commit
5c36fadf1a
36
DependencyInjection/ArrayConfig.php
Normal file
36
DependencyInjection/ArrayConfig.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\DependencyInjection;
|
||||
|
||||
/**
|
||||
* class ArrayConfig
|
||||
*
|
||||
* uses array as data source
|
||||
*/
|
||||
class ArrayConfig extends AbstractConfig
|
||||
{
|
||||
/**
|
||||
* Get parameter
|
||||
*
|
||||
* @param string|int $key
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user