1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Coco\SourceWatcher\Core; |
4
|
|
|
|
5
|
|
|
use ArrayAccess; |
6
|
|
|
|
7
|
|
|
class Row implements ArrayAccess, ArrayListAccess |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var array |
11
|
|
|
*/ |
12
|
|
|
private array $attributes; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Row constructor. |
16
|
|
|
* @param array $attributes |
17
|
|
|
*/ |
18
|
|
|
public function __construct ( array $attributes ) |
19
|
|
|
{ |
20
|
|
|
$this->attributes = $attributes; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
public function getAttributes () : array |
27
|
|
|
{ |
28
|
|
|
return $this->attributes; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param array $attributes |
33
|
|
|
*/ |
34
|
|
|
public function setAttributes ( array $attributes ) : void |
35
|
|
|
{ |
36
|
|
|
$this->attributes = $attributes; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function transform () |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritDoc |
46
|
|
|
*/ |
47
|
|
|
public function offsetExists ( $offset ) |
48
|
|
|
{ |
49
|
|
|
return array_key_exists( $offset, $this->attributes ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritDoc |
54
|
|
|
*/ |
55
|
|
|
public function offsetGet ( $offset ) |
56
|
|
|
{ |
57
|
|
|
return $this->attributes[$offset]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @inheritDoc |
62
|
|
|
*/ |
63
|
|
|
public function offsetSet ( $offset, $value ) |
64
|
|
|
{ |
65
|
|
|
$this->attributes[$offset] = $value; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritDoc |
70
|
|
|
*/ |
71
|
|
|
public function offsetUnset ( $offset ) |
72
|
|
|
{ |
73
|
|
|
unset( $this->attributes[$offset] ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function get ( string $key ) |
77
|
|
|
{ |
78
|
|
|
return $this->attributes[$key] ?? null; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function set ( string $key, $value ) : void |
82
|
|
|
{ |
83
|
|
|
$this->attributes[$key] = $value; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function remove ( string $key ) : void |
87
|
|
|
{ |
88
|
|
|
unset( $this->attributes[$key] ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function __get ( $key ) |
92
|
|
|
{ |
93
|
|
|
return $this->attributes[$key]; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function __set ( $key, $value ) |
97
|
|
|
{ |
98
|
|
|
$this->attributes[$key] = $value; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|