HasAttributes   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 2
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

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