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

Magic::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 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