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:58
created

ResultIterator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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 Iterator;
15
16
final class ResultIterator implements Iterator
17
{
18
    /**
19
     * @var Result[]
20
     */
21
    private $children;
22
23
    /**
24
     * Initializes the object.
25
     *
26
     * @param Result $result
27
     */
28
    public function __construct(Result $result)
29
    {
30
        $this->children = $result->getChildren();
31
    }
32
33
    public function current(): ?Result
34
    {
35
        $current = current($this->children);
36
        if (false === $current) {
37
            return null;
38
        }
39
40
        return $current;
41
    }
42
43
    public function next(): ?Result
44
    {
45
        $next = next($this->children);
46
        if (false == $next) {
47
            return null;
48
        }
49
50
        return $next;
51
    }
52
53
    public function key()
54
    {
55
        $current = $this->current();
56
        if (null === $current) {
57
            return null;
58
        }
59
60
        return $current->getProperties()['reference'] ?? key($this->children);
61
    }
62
63
    public function valid(): bool
64
    {
65
        return null !== $this->current();
66
    }
67
68
    public function rewind(): void
69
    {
70
        reset($this->children);
71
    }
72
}
73