service   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 13
dl 0
loc 21
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 9 3
A get() 0 9 3
1
<?php
2
3
/**
4
 * © 2018 - Phoponent
5
 * Author: Nicolas Choquet
6
 * Email: [email protected]
7
 * LICENSE GPL ( GNU General Public License )
8
 */
9
10
namespace phoponent\framework\traits;
11
12
trait service {
13
	public function get($name) {
14
		if(in_array($name, get_class_vars(get_class($this)))) {
15
			return $this->$name;
16
		}
17
		elseif (in_array("get_{$name}", get_class_methods($this))) {
18
			$func = "get_{$name}";
19
			return $this->$func();
20
		}
21
		return null;
22
	}
23
24
	public function set($name, $value) {
25
		if(in_array($name, array_keys(get_class_vars(get_class($this))))) {
26
			$this->$name = $value;
27
		}
28
		elseif (in_array("set_{$name}", get_class_methods($this))) {
29
			$func = "set_{$name}";
30
			return $this->$func($value);
31
		}
32
		return $this;
33
	}
34
}