Passed
Push — master ( 9c826d...8ef55e )
by smiley
03:03
created

Container::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
/**
3
 * Trait Container
4
 *
5
 * @filesource   Container.php
6
 * @created      09.07.2017
7
 * @package      chillerlan\QRCode
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\QRCode;
14
15
/**
16
 * a generic container with getter and setter
17
 * @codeCoverageIgnore
18
 */
19
trait Container{
20
21
	/**
22
	 * Boa constructor.
23
	 *
24
	 * @param array $properties
25
	 */
26
	public function __construct(array $properties = []){
27
28
		foreach($properties as $key => $value){
29
			$this->__set($key, $value);
30
		}
31
32
	}
33
34
	/**
35
	 * David Getter
36
	 *
37
	 * @param string $property
38
	 *
39
	 * @return mixed
40
	 */
41
	public function __get(string $property){
42
43
		if(property_exists($this, $property)){
44
			return $this->{$property};
45
		}
46
47
		return false;
48
	}
49
50
	/**
51
	 * Jet-setter
52
	 *
53
	 * @param string $property
54
	 * @param mixed  $value
55
	 *
56
	 * @return void
57
	 */
58
	public function __set(string $property, $value){
59
60
		if(property_exists($this, $property)){
61
			$this->{$property} = $value;
62
		}
63
64
	}
65
66
}
67