Passed
Pull Request — master (#415)
by
unknown
29:22 queued 26:39
created

IteratorWithBooleanKey::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Support\Data;
6
7
use ReturnTypeWillChange;
8
use Yiisoft\Validator\Rule\HasLength;
9
use Yiisoft\Validator\RuleInterface;
10
11
class IteratorWithBooleanKey implements \Iterator
12
{
13
    private int $position = 0;
14
    private array $array;
15
16
    public function __construct()
17
    {
18
        $this->array = [new HasLength(min: 1), new HasLength(min: 1)];
19
    }
20
21
    public function rewind(): void
22
    {
23
        $this->position = 0;
24
    }
25
26
    #[ReturnTypeWillChange]
27
    public function current(): RuleInterface
28
    {
29
        return $this->array[$this->position];
30
    }
31
32
    #[ReturnTypeWillChange]
33
    public function key(): bool
34
    {
35
        return (bool) $this->position;
36
    }
37
38
    public function next(): void
39
    {
40
        ++$this->position;
41
    }
42
43
    public function valid(): bool
44
    {
45
        return isset($this->array[$this->position]);
46
    }
47
}
48