Passed
Push — master ( 17e6cc...350d8b )
by Aleksandr
41:29 queued 06:24
created

AttributeBag::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 *
5
 * @author    Alex Kuperwood <[email protected]>
6
 * @copyright 2025 Alex Kuperwood
7
 * @license   https://opensource.org/license/mit  The MIT License
8
 */
9
declare(strict_types=1);
10
11
namespace Kuperwood\Eav;
12
13
use Kuperwood\Eav\Enum\_ATTR;
14
15
class AttributeBag
16
{
17
    private array $data;
18
19 1
    public function __construct()
20
    {
21 1
        $this->data = _ATTR::bag();
22
    }
23
24 1
    public function setField($field, $value): self
25
    {
26 1
        $this->data[$field] = $value;
27
28 1
        return $this;
29
    }
30
31 1
    public function getField($field)
32
    {
33 1
        return $this->data[$field];
34
    }
35
36 1
    public function resetField($field): self
37
    {
38 1
        $this->data[$field] = _ATTR::bag($field);
39
40 1
        return $this;
41
    }
42
43 2
    public function getFields(): array
44
    {
45 2
        return $this->data;
46
    }
47
48 1
    public function setFields(array $fields): self
49
    {
50 1
        $this->data = $fields;
51
52 1
        return $this;
53
    }
54
}
55