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
05:02
created

ResultIterator::rewind()   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 0
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 Countable;
15
use Iterator;
16
17
class ResultIterator implements Countable, Iterator
18
{
19
    /**
20
     * @var Result[]
21
     */
22
    private $children;
23
24
    /**
25
     * Initializes the object.
26
     *
27
     * @param Result $result
28
     */
29
    public function __construct(Result $result)
30
    {
31
        $this->children = $result->getChildren();
32
    }
33
34
    public function current(): ?Result
35
    {
36
        $current = current($this->children);
37
        if (false === $current) {
38
            return null;
39
        }
40
41
        return $current;
42
    }
43
44
    public function next(): ?Result
45
    {
46
        $next = next($this->children);
47
        if (false == $next) {
48
            return null;
49
        }
50
51
        return $next;
52
    }
53
54
    public function key()
55
    {
56
        $current = $this->current();
57
        if (null === $current) {
58
            return null;
59
        }
60
61
        return $current->getProperties()['reference'] ?? key($this->children);
62
    }
63
64
    public function valid(): bool
65
    {
66
        return null !== $this->current();
67
    }
68
69
    public function rewind(): void
70
    {
71
        reset($this->children);
72
    }
73
    public function count(): int
74
    {
75
        return count($this->children);
76
    }
77
}
78