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
03:10
created

ResultIterator::getChildren()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 6
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation;
13
14
use Countable;
15
use Exception;
16
use RecursiveIterator;
17
18
final class ResultIterator implements RecursiveIterator, Countable
19
{
20
    /**
21
     * @var Result[]
22
     */
23
    private $children;
24
25
    public function __construct(Result $result)
26
    {
27
        $this->children = $result->getChildren();
28
    }
29
30
    public function current(): ?Result
31
    {
32
        $current = current($this->children);
33
        if (false === $current) {
34
            return null;
35
        }
36
37
        return $current;
38
    }
39
40
    public function next(): ?Result
41
    {
42
        $next = next($this->children);
43
        if (false == $next) {
44
            return null;
45
        }
46
47
        return $next;
48
    }
49
50
    public function key()
51
    {
52
        $current = $this->current();
53
        if (null === $current) {
54
            return null;
55
        }
56
57
        return $current->getProperties()['reference'] ?? key($this->children);
58
    }
59
60
    public function valid(): bool
61
    {
62
        return null !== $this->current();
63
    }
64
65
    public function rewind(): void
66
    {
67
        reset($this->children);
68
    }
69
70
    public function hasChildren(): bool
71
    {
72
        $children = $this->current()->getChildren();
73
74
        return count($children) > 0;
75
    }
76
77
    public function getChildren(): ResultIterator
78
    {
79
        $current = $this->current();
80
        if (null === $current) {
81
            throw new Exception();
82
        }
83
84
        return new self($current);
85
    }
86
87
    public function count(): int
88
    {
89
        return count($this->children);
90
    }
91
}
92