ArrayFieldsTrait::setFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the geo-api-library package.
5
 *
6
 * (c) 2020 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\GeoAPI\Model\Attribute;
13
14
/**
15
 * Array fields trait.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Library\GeoAPI\Model\Attribute
19
 */
20
trait ArrayFieldsTrait {
21
22
    /**
23
     * Fields
24
     *
25
     * @var string[]
26
     */
27
    private $fields;
28
29
    /**
30
     * Add a field.
31
     *
32
     * @param string $field The field.
33
     * @return self Returns tis instance.
34
     */
35 5
    public function addField(string $field): self {
36 5
        $this->fields[] = $field;
37 5
        return $this;
38
    }
39
40
    /**
41
     * Get the fields.
42
     *
43
     * @return string[] Returns the fields.
44
     */
45 15
    public function getFields(): array {
46 15
        return $this->fields;
47
    }
48
49
    /**
50
     * Set the fields.
51
     *
52
     * @param string[] $fields The fields.
53
     * @return self Returns tis instance.
54
     */
55 180
    protected function setFields(array $fields): self {
56 180
        $this->fields = $fields;
57 180
        return $this;
58
    }
59
}