Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#678)
by Henrique
02:51
created

ResultIterator   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 58
c 0
b 0
f 0
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A current() 0 4 1
A next() 0 4 1
A key() 0 6 1
A valid() 0 6 2
A rewind() 0 4 1
A hasChildren() 0 6 1
A getChildren() 0 4 1
A count() 0 4 1
1
<?php
2
3
4
namespace Respect\Validation;
5
6
use Countable;
7
use RecursiveIterator;
8
9
final class ResultIterator implements RecursiveIterator, Countable
10
{
11
    /**
12
     * @var Result[]
13
     */
14
    private $children;
15
16
    public function __construct(Result $result)
17
    {
18
        $this->children = $result->getChildren();
19
    }
20
21
    public function current()
22
    {
23
        return current($this->children);
24
    }
25
26
    public function next()
27
    {
28
        return next($this->children);
29
    }
30
31
    public function key()
32
    {
33
        $current = current($this->children);
34
35
        return $current->getProperties()['reference'] ?? key($this->children);
36
    }
37
38
    public function valid(): bool
39
    {
40
        $key = key($this->children);
41
42
        return ($key !== null && $key !== false);
43
    }
44
45
    public function rewind()
46
    {
47
        reset($this->children);
48
    }
49
50
    public function hasChildren(): bool
51
    {
52
        $children = $this->current()->getChildren();
53
54
        return count($children) > 0;
55
    }
56
57
    public function getChildren(): ResultIterator
58
    {
59
        return new self($this->current());
0 ignored issues
show
Security Bug introduced by
It seems like $this->current() targeting Respect\Validation\ResultIterator::current() can also be of type false; however, Respect\Validation\ResultIterator::__construct() does only seem to accept object<Respect\Validation\Result>, did you maybe forget to handle an error condition?
Loading history...
60
    }
61
62
    public function count(): int
63
    {
64
        return count($this->children);
65
    }
66
}
67