KeyValueObjectAccessTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __isset() 0 3 1
A __get() 0 3 1
A __unset() 0 3 1
A __set() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Nexus\Traits;
6
7
/**
8
 * Magic methods for KeyValueInterface, makes it's content accessible as object properties.
9
 */
10
trait KeyValueObjectAccessTrait
11
{
12
    public function __get($name)
13
    {
14
        return $this->get($name);
15
    }
16
17
    public function __set($name, $value)
18
    {
19
        $this->set($name, $value);
20
    }
21
22
    public function __isset($name)
23
    {
24
        return $this->exists($name);
25
    }
26
27
    public function __unset($name)
28
    {
29
        $this->delete($name);
30
    }
31
32
    abstract public function set(string $key, $value);
33
34
    abstract public function delete(string $key);
35
36
    abstract public function get(string $key);
37
38
    abstract public function exists(string $key);
39
}
40