Passed
Push — master ( 0cda2e...f3fa1e )
by Aimeos
17:16 queued 07:34
created

Base::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2021
7
 * @package MW
8
 * @subpackage Config
9
 */
10
11
12
namespace Aimeos\MW\Config\Decorator;
13
14
15
/**
16
 * Base class for all config decorators.
17
 *
18
 * @package MW
19
 * @subpackage Config
20
 */
21
abstract class Base implements \Aimeos\MW\Config\Decorator\Iface
22
{
23
	private $object;
24
25
26
	/**
27
	 * Initializes the decorator.
28
	 *
29
	 * @param \Aimeos\MW\Config\Iface $object Config object or decorator
30
	 */
31
	public function __construct( \Aimeos\MW\Config\Iface $object )
32
	{
33
		$this->object = $object;
34
	}
35
36
37
	/**
38
	 * Clones the objects inside.
39
	 */
40
	public function __clone()
41
	{
42
		$this->object = clone $this->object;
43
	}
44
45
46
	/**
47
	 * Adds the given configuration and overwrite already existing keys.
48
	 *
49
	 * @param array $config Associative list of (multi-dimensional) configuration settings
50
	 * @return \Aimeos\MW\Config\Iface Config instance for method chaining
51
	 */
52
	public function apply( array $config ) : \Aimeos\MW\Config\Iface
53
	{
54
		$this->object->apply( $config );
55
		return $this;
56
	}
57
58
59
	/**
60
	 * Returns the value of the requested config key.
61
	 *
62
	 * @param string $path Path to the requested value like tree/node/classname
63
	 * @param mixed $default Value returned if requested key isn't found
64
	 * @return mixed Value associated to the requested key
65
	 */
66
	public function get( string $path, $default = null )
67
	{
68
		return $this->object->get( $path, $default );
69
	}
70
71
72
	/**
73
	 * Sets the value for the specified key.
74
	 *
75
	 * @param string $path Path to the requested value like tree/node/classname
76
	 * @param mixed $value Value that should be associated with the given path
77
	 */
78
	public function set( string $path, $value ) : \Aimeos\MW\Config\Iface
79
	{
80
		$this->object->set( $path, $value );
81
		return $this;
82
	}
83
84
85
	/**
86
	 * Returns the wrapped config object.
87
	 *
88
	 * @return \Aimeos\MW\Config\Iface Config object
89
	 */
90
	protected function object() : \Aimeos\MW\Config\Iface
91
	{
92
		return $this->object;
93
	}
94
}
95