Passed
Push — master ( 5f46f3...33b3f8 )
by compolom
06:13
created

Entity::__call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 2
crap 3
1
<?php declare(strict_types=1);
2
3
namespace DrMVC\Orm;
4
5
/**
6
 * Class Entity
7
 * @package DrMVC\Orm
8
 *
9
 * @property int id
10
 * @method Entity getId(): int
11
 */
12
class Entity
13
{
14
    /**
15
     * Magic container
16
     *
17
     * @var array
18
     */
19
    private $data = [];
20
21
    /**
22
     * Get all fields
23
     *
24
     * @return array
25
     */
26 2
    public function getData(): array
27
    {
28 2
        return $this->data;
29
    }
30
31
    /**
32
     * @param string $name
33
     * @return mixed|null
34
     */
35 5
    public function __get(string $name)
36
    {
37 5
        return $this->data[$name] ?? null;
38
    }
39
40
    /**
41
     * @param string $name
42
     * @param $value
43
     */
44 8
    public function __set(string $name, $value)//: void 7.1
45
    {
46 8
        $this->data[$name] = $value;
47 8
    }
48
49
    /**
50
     * @param string $name
51
     * @return bool
52
     */
53 1
    public function __isset(string $name): bool
54
    {
55 1
        return isset($this->data[$name]);
56
    }
57
58
    /**
59
     * @param string $name
60
     */
61 1
    public function __unset(string $name)//: void 7.1
62
    {
63 1
        unset($this->data[$name]);
64 1
    }
65
}
66