HasPropertiesTrait::addProperty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Phact\Container\Details;
4
5
trait HasPropertiesTrait
6
{
7
    /**
8
     * @var Property[]
9
     */
10
    protected $properties = [];
11
12
13
    /**
14
     * @return Property[]
15
     */
16 14
    public function getProperties(): array
17
    {
18 14
        return $this->properties;
19
    }
20
21
    /**
22
     * @param string $name
23
     * @param mixed $value
24
     * @return self
25
     */
26 4
    public function addProperty(string $name, $value): self
27
    {
28 4
        $this->properties[] = new Property($name, $value);
29 4
        return $this;
30
    }
31
32
    /**
33
     * @return self
34
     */
35 1
    public function removeProperties(): self
36
    {
37 1
        $this->properties = [];
38 1
        return $this;
39
    }
40
}
41