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

IteratorWithBooleanKey   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A rewind() 0 3 1
A current() 0 4 1
A next() 0 3 1
A key() 0 4 1
A __construct() 0 3 1
A valid() 0 3 1
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