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

Magic   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 26
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
 * 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