TestCollection   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 25
c 5
b 0
f 0
dl 0
loc 70
rs 10
wmc 11

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isEmpty() 0 3 1
A valid() 0 3 1
A current() 0 4 1
A next() 0 3 1
A rewind() 0 3 1
A key() 0 4 1
A __construct() 0 26 5
1
<?php
2
3
namespace OckCyp\CoversValidator\Model;
4
5
use PHPUnit\Util\Configuration as PHPUnit8Configuration;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Util\Configuration 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...
6
7
class TestCollection implements \Iterator
8
{
9
    /**
10
     * @var \Iterator
11
     */
12
    private $iterator;
13
14
    /**
15
     * @var \Iterator
16
     */
17
    private $iteratorIterator;
18
19
    public function __construct(ConfigurationHolder $configurationHolder)
20
    {
21
        $configuration = $configurationHolder->getConfiguration();
22
23
        if ($configuration instanceof PHPUnit8Configuration) {
24
            // @codeCoverageIgnoreStart
25
            $this->iterator = $configuration->getTestSuiteConfiguration();
26
        } else {
27
            if (class_exists('PHPUnit\TextUI\Configuration\TestSuiteMapper', true)) {
28
                // PHPUnit < 9.3
29
                $testSuiteMapper = new \PHPUnit\TextUI\Configuration\TestSuiteMapper();
0 ignored issues
show
Bug introduced by
The type PHPUnit\TextUI\Configuration\TestSuiteMapper 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...
30
            } elseif (class_exists('PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper', true)) {
31
                // PHPUnit >= 9.3 & < 9.5
32
                $testSuiteMapper = new \PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper();
0 ignored issues
show
Bug introduced by
The type PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper 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...
33
            // @codeCoverageIgnoreEnd
34
            } elseif (class_exists('PHPUnit\TextUI\TestSuiteMapper', true)) {
35
                // PHPUnit >= 9.5
36
                $testSuiteMapper = new \PHPUnit\TextUI\TestSuiteMapper();
37
            } else {
38
                throw new \RuntimeException('Could not find PHPUnit TestSuiteMapper class'); // @codeCoverageIgnore
39
            }
40
41
            $this->iterator = $testSuiteMapper->map($configuration->testSuite(), '');
0 ignored issues
show
Documentation Bug introduced by
It seems like $testSuiteMapper->map($c...ation->testSuite(), '') of type PHPUnit\Framework\TestSuite is incompatible with the declared type Iterator of property $iterator.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        }
43
44
        $this->iteratorIterator = new \RecursiveIteratorIterator($this->iterator);
45
    }
46
47
    #[\ReturnTypeWillChange]
48
    public function current()
49
    {
50
        return $this->iteratorIterator->current();
51
    }
52
53
    #[\ReturnTypeWillChange]
54
    public function key()
55
    {
56
        return $this->iteratorIterator->key();
57
    }
58
59
    public function next(): void
60
    {
61
        $this->iteratorIterator->next();
62
    }
63
64
    public function rewind(): void
65
    {
66
        $this->iteratorIterator->rewind();
67
    }
68
69
    public function valid(): bool
70
    {
71
        return $this->iteratorIterator->valid();
72
    }
73
74
    public function isEmpty(): bool
75
    {
76
        return !\count($this->iterator);
0 ignored issues
show
Bug introduced by
$this->iterator of type Iterator is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
        return !\count(/** @scrutinizer ignore-type */ $this->iterator);
Loading history...
77
    }
78
}
79