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

Container   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 48
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A __get() 0 8 2
A __set() 0 7 2
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