Completed
Pull Request — master (#27)
by Oliver
01:17
created

TestCollection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
lcom 2
cbo 3
dl 0
loc 57
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A current() 0 4 1
A key() 0 4 1
A next() 0 4 1
A rewind() 0 4 1
A valid() 0 4 1
A isEmpty() 0 4 1
1
<?php
2
3
namespace OckCyp\CoversValidator\Model;
4
5
use PHPUnit\Util\Configuration as PHPUnit8Configuration;
6
use PHPUnit\TextUI\Configuration\TestSuiteMapper;
7
8
class TestCollection implements \Iterator
9
{
10
    /**
11
     * @var \Iterator
12
     */
13
    private $iterator;
14
15
    /**
16
     * @var \Iterator
17
     */
18
    private $iteratorIterator;
19
20
    public function __construct(ConfigurationHolder $configurationHolder)
21
    {
22
        $configuration = $configurationHolder->getConfiguration();
23
24
        if ($configuration instanceof PHPUnit8Configuration) {
0 ignored issues
show
Bug introduced by
The class PHPUnit\Util\Configuration does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
25
            $this->iterator = $configuration->getTestSuiteConfiguration();
26
        } else {
27
            $testSuiteMapper = new TestSuiteMapper();
28
29
            $this->iterator = $testSuiteMapper->map($configuration->testSuite(), '');
0 ignored issues
show
Documentation Bug introduced by
It seems like $testSuiteMapper->map($c...ation->testSuite(), '') of type object<PHPUnit\Framework\TestSuite> is incompatible with the declared type object<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...
30
        }
31
32
        $this->iteratorIterator = new \RecursiveIteratorIterator($this->iterator);
33
    }
34
35
    public function current()
36
    {
37
        return $this->iteratorIterator->current();
38
    }
39
40
    public function key()
41
    {
42
        return $this->iteratorIterator->key();
43
    }
44
45
    public function next()
46
    {
47
        $this->iteratorIterator->next();
48
    }
49
50
    public function rewind()
51
    {
52
        $this->iteratorIterator->rewind();
53
    }
54
55
    public function valid(): bool
56
    {
57
        return $this->iteratorIterator->valid();
58
    }
59
60
    public function isEmpty(): bool
61
    {
62
        return !\count($this->iterator);
63
    }
64
}
65