Completed
Push — master ( 523298...58621f )
by smiley
02:46
created

Magic::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * Trait Magic
4
 *
5
 * @filesource   Magic.php
6
 * @created      11.05.2017
7
 * @package      chillerlan\Database\Traits
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Traits;
14
15
trait Magic{
16
17
	public function __get(string $name) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
		return $this->get($name);
19
	}
20
21
	public function __set(string $name, $value) {
22
		$this->set($name, $value);
23
	}
24
25
	private function get(string $name) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
26
		$method = 'magic_get_'.$name;
27
28
		return method_exists($this, $method) ? $this->$method() : null;
29
	}
30
31
	private function set(string $name, $value) {
32
		$method = 'magic_set_'.$name;
33
34
		if(method_exists($this, $method)){
35
			$this->$method($value);
36
		}
37
38
	}
39
40
}
41