ArrayIterator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace EasyHttp\MockBuilder\Iterators;
4
5
class ArrayIterator implements \Iterator
6
{
7
    private array $collection = [];
8
9 117
    public function __construct(array $collection)
10
    {
11 117
        $this->collection = $collection;
12
    }
13
14 44
    public function next(): void
15
    {
16 44
        next($this->collection);
17
    }
18
19 117
    public function key(): ?string
20
    {
21 117
        return key($this->collection);
22
    }
23
24 117
    public function valid(): bool
25
    {
26 117
        return array_key_exists($this->key(), $this->collection);
27
    }
28
29 117
    public function rewind(): void
30
    {
31 117
        reset($this->collection);
32
    }
33
34
    #[\ReturnTypeWillChange]
35 94
    public function current()
36
    {
37 94
        return current($this->collection);
38
    }
39
}
40