1 | <?php |
||
5 | trait HasAttributesTrait |
||
6 | { |
||
7 | /** @var array $attributes */ |
||
8 | private $attributes = []; |
||
9 | |||
10 | /** |
||
11 | * @param $key |
||
12 | * @return mixed|null |
||
13 | */ |
||
14 | 2 | public function getAttribute($key) |
|
15 | 2 | { |
|
16 | 2 | return isset($this->attributes[$key]) ? $this->attributes[$key] : null; |
|
17 | } |
||
18 | |||
19 | /** |
||
20 | * @param string $key |
||
21 | * @param $value |
||
22 | * @return $this |
||
23 | */ |
||
24 | 1 | public function setAttribute(string $key, $value) |
|
25 | 1 | { |
|
26 | 1 | $this->attributes[$key] = $value; |
|
27 | 1 | return $this; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param array $attributes |
||
32 | * @return $this |
||
33 | */ |
||
34 | 20 | public function setAttributes(array $attributes) |
|
39 | |||
40 | /** |
||
41 | * @return array |
||
42 | */ |
||
43 | 1 | public function getAttributes() |
|
47 | } |
||
48 |