Passed
Branch master (fb2e38)
by Sebastian
02:23
created

IteratorTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 2
A rewind() 0 3 1
A next() 0 3 1
A valid() 0 3 1
A key() 0 3 1
1
<?php
2
3
namespace Seboettg\Collection\NativePhp;
4
5
trait IteratorTrait
6
{
7
    private int $offset = 0;
0 ignored issues
show
Coding Style introduced by
Private member variable "offset" must contain a leading underscore
Loading history...
8
    /**
9
     * {@inheritdoc}
10
     */
11 20
    public function current()
12
    {
13 20
        return $this->valid() ? $this->array[$this->offset] : false;
14
    }
15
16 2
    public function key(): int
17
    {
18 2
        return $this->offset;
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 18
    public function next(): void
25
    {
26 18
        ++$this->offset;
27 18
    }
28
29 20
    public function valid(): bool
30
    {
31 20
        return isset($this->array[$this->offset]);
32
    }
33
34 19
    public function rewind(): void
35
    {
36 19
        $this->offset = 0;
37 19
    }
38
}
39