ResultCollected::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
c 0
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 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