HasFields   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 48
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setFields() 0 5 1
A addField() 0 7 1
A getFields() 0 3 1
1
<?php
2
3
namespace BlockListCheck\Checkers;
4
5
trait HasFields
6
{
7
8
    /**
9
     * Fields to check.
10
     *
11
     * @var array
12
     */
13
    protected array $fields = [];
14
15
    /**
16
     * Fields to check.
17
     *
18
     * @return array
19
     */
20 3
    public function getFields(): array
21
    {
22 3
        return $this->fields;
23
    }
24
25
    /**
26
     * Set fields.
27
     *
28
     * @param array $fields
29
     *
30
     * @return static
31
     */
32 11
    public function setFields(array $fields): static
33
    {
34 11
        $this->fields = array_unique($fields);
35
36 11
        return $this;
37
    }
38
39
    /**
40
     * Add field to list.
41
     *
42
     * @param string $field
43
     *
44
     * @return static
45
     */
46 2
    public function addField(string $field): static
47
    {
48 2
        array_push($this->fields, $field);
49
50 2
        $this->fields = array_unique($this->fields);
51
52 2
        return $this;
53
    }
54
}
55