Total Complexity | 12 |
Total Lines | 102 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | class Memory |
||
21 | extends \Aimeos\Base\Config\Decorator\Base |
||
22 | implements \Aimeos\Base\Config\Decorator\Iface |
||
23 | { |
||
24 | private array $negCache = []; |
||
25 | private array $cache = []; |
||
26 | private array $config; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * Initializes the decorator. |
||
31 | * |
||
32 | * @param \Aimeos\Base\Config\Iface $object Config object or decorator |
||
33 | * @param array $config Pre-cached non-shared configuration |
||
34 | */ |
||
35 | public function __construct( \Aimeos\Base\Config\Iface $object, array $config = [] ) |
||
40 | } |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Returns the value of the requested config key. |
||
45 | * |
||
46 | * @param string $name Path to the requested value like tree/node/classname |
||
47 | * @param mixed $default Value returned if requested key isn't found |
||
48 | * @return mixed Value associated to the requested key |
||
49 | */ |
||
50 | public function get( string $name, $default = null ) |
||
74 | } |
||
75 | |||
76 | |||
77 | /** |
||
78 | * Sets the value for the specified key. |
||
79 | * |
||
80 | * @param string $name Path to the requested value like tree/node/classname |
||
81 | * @param string $value Value that should be associated with the given path |
||
82 | * @return \Aimeos\Base\Config\Iface Config instance for method chaining |
||
83 | */ |
||
84 | public function set( string $name, $value ) : \Aimeos\Base\Config\Iface |
||
85 | { |
||
86 | $name = trim( $name, '/' ); |
||
87 | |||
88 | if( $value !== null ) |
||
|
|||
89 | { |
||
90 | $this->cache[$name] = $value; |
||
91 | unset( $this->negCache[$name] ); |
||
92 | } |
||
93 | else |
||
94 | { |
||
95 | $this->negCache[$name] = true; |
||
96 | } |
||
97 | |||
98 | // don't store local configuration |
||
99 | return $this; |
||
100 | } |
||
101 | |||
102 | |||
103 | /** |
||
104 | * Returns the requested configuration value from the given array |
||
105 | * |
||
106 | * @param array $config The array to search in |
||
107 | * @param array $parts Configuration path parts to look for inside the array |
||
108 | * @return mixed Found configuration value or null if not available |
||
109 | */ |
||
110 | protected function getValueFromArray( array $config, array $parts ) |
||
122 | } |
||
123 | } |
||
124 |