Row::__get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Coco\SourceWatcher\Core;
4
5
use ArrayAccess;
6
7
/**
8
 * Class Row
9
 * @package Coco\SourceWatcher\Core
10
 */
11
class Row implements ArrayAccess, ArrayListAccess
12
{
13
    private array $attributes;
14
15
    public function __construct ( array $attributes )
16
    {
17
        $this->attributes = $attributes;
18
    }
19
20
    public function getAttributes () : array
21
    {
22
        return $this->attributes;
23
    }
24
25
    public function setAttributes ( array $attributes ) : void
26
    {
27
        $this->attributes = $attributes;
28
    }
29
30
    public function offsetExists ( $offset )
31
    {
32
        return array_key_exists( $offset, $this->attributes );
33
    }
34
35
    public function offsetGet ( $offset )
36
    {
37
        return $this->attributes[$offset];
38
    }
39
40
    public function offsetSet ( $offset, $value )
41
    {
42
        $this->attributes[$offset] = $value;
43
    }
44
45
    public function offsetUnset ( $offset )
46
    {
47
        unset( $this->attributes[$offset] );
48
    }
49
50
    public function get ( string $key )
51
    {
52
        return $this->attributes[$key] ?? null;
53
    }
54
55
    public function set ( string $key, $value ) : void
56
    {
57
        $this->attributes[$key] = $value;
58
    }
59
60
    public function remove ( string $key ) : void
61
    {
62
        unset( $this->attributes[$key] );
63
    }
64
65
    public function __get ( $key )
66
    {
67
        return $this->attributes[$key];
68
    }
69
70
    public function __set ( $key, $value )
71
    {
72
        $this->attributes[$key] = $value;
73
    }
74
}
75