Completed
Push — master ( e52a1e...5c6bea )
by Daniel
02:19
created

LocationIterator::key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Jobles\Core\Location;
4
5 View Code Duplication
class LocationIterator implements \Iterator, \Countable
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    /**
8
     * @var int
9
     */
10
    private $position = 0;
11
12
    /**
13
     * @var LocationCollection
14
     */
15
    private $locations;
16
17 10
    public function __construct(LocationCollection $locationCollection)
18
    {
19 10
        $this->locations = $locationCollection;
20 10
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25 2
    public function current()
26
    {
27 2
        return $this->locations->pick($this->position);
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33 6
    public function next()
34
    {
35 6
        ++$this->position;
36 6
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41 1
    public function key()
42
    {
43 1
        return $this->position;
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49 2
    public function valid()
50
    {
51 2
        return $this->position < $this->locations->count();
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57 1
    public function rewind()
58
    {
59 1
        $this->position = 0;
60 1
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65 1
    public function count()
66
    {
67 1
        return $this->locations->count();
68
    }
69
}
70