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

AttributeBag   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setField() 0 5 1
A getField() 0 3 1
A resetField() 0 5 1
A getFields() 0 3 1
A setFields() 0 5 1
A __construct() 0 3 1
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