Passed
Push — ft/pagefield ( db2ad6...f2722b )
by Ben
10:27
created

DetailSections::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Thinktomorrow\Chief\Management\Details;
6
7
use Illuminate\Contracts\Support\Arrayable;
8
9
class DetailSections implements Arrayable
10
{
11
    /** @var array */
12
    protected $values = [];
13
14
    public function get($attribute = null)
15
    {
16
        if (array_key_exists($attribute, $this->values)) {
17
            return $this->values[$attribute];
18
        }
19
20
        return null;
21
    }
22
23
    public function has($attribute): bool
24
    {
25
        return null !== $this->get($attribute);
26
    }
27
28
    public function set($attribute, $value)
29
    {
30
        $this->values[$attribute] = $value;
31
32
        return $this;
33
    }
34
35
    public function __get($attribute)
36
    {
37
        return $this->get($attribute);
38
    }
39
40
    public function __set($attribute, $value)
41
    {
42
        return $this->set($attribute, $value);
43
    }
44
45
    public function __toString()
46
    {
47
        return (string)$this->get('key');
48
    }
49
50
    /**
51
     * Get the instance as an array.
52
     *
53
     * @return array
54
     */
55
    public function toArray()
56
    {
57
        return $this->values;
58
    }
59
}
60