Passed
Push — ft/dynamic-attributes ( 48373f )
by Ben
11:13
created

DynamicAttributes::set()   A

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 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Thinktomorrow\Chief\DynamicAttributes;
5
6
class DynamicAttributes
7
{
8
    /** @var array */
9
    private $values;
10
11
    public function __construct(array $values)
12
    {
13
        $this->values = $values;
14
    }
15
16
    public function has(string $key): bool
17
    {
18
        return ($this->get($key, '__NOTFOUND__') !== '__NOTFOUND__');
19
    }
20
21
    public function get(string $key, $default = null)
22
    {
23
        return data_get($this->values, $key, $default);
24
    }
25
26
    public function set(string $key, $value)
27
    {
28
        data_set($this->values, $key, $value);
29
    }
30
31
    public function all()
32
    {
33
        return $this->values;
34
    }
35
}
36