Completed
Push — master ( 14b45d...d8ec9e )
by smiley
04:40
created

Magic   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 3 1
A __set() 0 3 1
A get() 0 5 2
A set() 0 8 2
1
<?php
2
/**
3
 *
4
 * @filesource   Magic.php
5
 * @created      11.05.2017
6
 * @package      chillerlan\PrototypeDOM\Traits
7
 * @author       Smiley <[email protected]>
8
 * @copyright    2017 Smiley
9
 * @license      MIT
10
 */
11
12
namespace chillerlan\PrototypeDOM\Traits;
13
14
/**
15
 * Trait Magic
16
 */
17
trait Magic{
18
19 21
	public function __get($name) {
20 21
		return $this->get($name);
21
	}
22
23 5
	public function __set($name, $value) {
24 5
		$this->set($name, $value);
25 5
	}
26
27 21
	private function get($name) {
28 21
		$method = 'magic_get_'.$name;
29
30 21
		return method_exists($this, $method) ? $this->$method() : null;
31
	}
32
33 5
	private function set($name, $value) {
34 5
		$method = 'magic_set_'.$name;
35
36 5
		if(method_exists($this, $method)){
37 5
			$this->$method($value);
38
		}
39
40 5
	}
41
42
}
43