ResultCollected   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 5
c 0
b 0
f 0
dl 0
loc 34
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A emptyResult() 0 3 1
A getIterator() 0 3 1
A addResult() 0 3 1
A count() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace NamespaceProtector\Result;
6
7
use Iterator;
8
use ArrayIterator;
9
10
/**
11
 * @template T
12
 * @implements ResultCollectedInterface<T>
13
 */
14
final class ResultCollected implements ResultCollectedInterface
15
{
16
    /**
17
     * @param  array<int, T> $list
18
     */
19
    public function __construct(private array $list = [])
20
    {
21
    }
22
23
    /**
24
     * @param T $list
0 ignored issues
show
Bug introduced by
The type NamespaceProtector\Result\T was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
     * @return void
26
     */
27
    public function addResult($list): void
28
    {
29
        $this->list[] = $list;
30
    }
31
32
    public function count(): int
33
    {
34
        return \count($this->list);
35
    }
36
37
    public function emptyResult(): void
38
    {
39
        $this->list = [];
40
    }
41
42
    /**
43
     * @return Iterator<T>
44
     */
45
    public function getIterator(): Iterator
46
    {
47
        return new ArrayIterator($this->list);
48
    }
49
}
50