Completed
Push — master ( ad24bf...d452c0 )
by Ricardo
168:19 queued 133:59
created

ErrorCollection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 39
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 4 1
A removeElement() 0 10 2
A add() 0 6 1
A clear() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace RicardoFiorani\Validator\Response\Error\Collection;
4
5
use RicardoFiorani\Validator\Response\Error\ValidationErrorInterface;
6
7
class ErrorCollection
8
{
9
    private $elements;
10
11 10
    public function __construct()
12
    {
13 10
        $this->elements = [];
14 10
    }
15
16 9
    public function toArray(): array
17
    {
18 9
        return $this->elements;
19
    }
20
21 1
    public function removeElement(ValidationErrorInterface $element): self
22
    {
23 1
        $key = array_search($element, $this->elements, true);
24
25 1
        if ($key !== false) {
26 1
            unset($this->elements[$key]);
27
        }
28
29 1
        return $this;
30
    }
31
32 7
    public function add(ValidationErrorInterface $element): self
33
    {
34 7
        $this->elements[] = $element;
35
36 7
        return $this;
37
    }
38
39 1
    public function clear(): self
40
    {
41 1
        $this->elements = [];
42
43 1
        return $this;
44
    }
45
}
46