Completed
Push — master ( a7254e...36f428 )
by BruceScrutinizer
01:47
created

ResultCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 1
b 1
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A emptyResult() 0 3 1
A addResult() 0 3 1
A count() 0 3 1
A get() 0 3 1
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace NamespaceProtector\Result;
4
5
final class ResultCollector implements ResultCollectorInterface
6
{
7
    /** @var array<ResultInterface>  */
8
    private $listResult;
9
10
    /**
11
     * @param array<ResultInterface> $result
12
     */
13
    public function __construct(array $result = [])
14
    {
15
        $this->listResult = $result;
16
    }
17
18
    public function addResult(ResultInterface $result): void
19
    {
20
        $this->listResult[] = $result;
21
    }
22
23
    public function count(): int
24
    {
25
        return \count($this->listResult);
26
    }
27
28
    /** @return  array<ResultInterface>  */
29
    public function get(): array
30
    {
31
        return $this->listResult;
32
    }
33
34
    public function emptyResult(): void
35
    {
36
        $this->listResult = [];
37
    }
38
}
39