Passed
Push — master ( 259c4a...d70309 )
by Shane
13:37
created

HasAttributes   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 29
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __unset() 0 3 1
A __set() 0 5 1
A __get() 0 7 2
A __isset() 0 3 1
1
<?php
2
3
4
namespace ElegantMedia\PHPToolkit\Types;
5
6
7
trait HasAttributes
8
{
9
10
	protected $attributes;
11
12
	public function __set($name, $value)
13
	{
14
		$this->attributes[$name] = $value;
15
16
		return $this;
17
	}
18
19
	public function __get($name)
20
	{
21
		if (!array_key_exists($name, $this->attributes)) {
22
			return null;
23
		}
24
25
		return $this->attributes[$name];
26
	}
27
28
	public function __isset($name)
29
	{
30
		return isset($this->attributes[$name]);
31
	}
32
33
	public function __unset($name)
34
	{
35
		unset($this->attributes[$name]);
36
	}
37
38
}
39