HasFields::getFields()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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