Code Duplication    Length = 65-65 lines in 2 locations

src/Job/JobIterator.php 1 location

@@ 5-69 (lines=65) @@
2
3
namespace Jobles\Core\Job;
4
5
class JobIterator implements \Iterator, \Countable
6
{
7
    /**
8
     * @var int
9
     */
10
    private $position = 0;
11
12
    /**
13
     * @var JobCollection
14
     */
15
    private $jobs;
16
17
    public function __construct(JobCollection $jobCollection)
18
    {
19
        $this->jobs = $jobCollection;
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function current()
26
    {
27
        return $this->jobs->pick($this->position);
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function next()
34
    {
35
        ++$this->position;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function key()
42
    {
43
        return $this->position;
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function valid()
50
    {
51
        return $this->position < $this->count();
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57
    public function rewind()
58
    {
59
        $this->position = 0;
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65
    public function count()
66
    {
67
        return count($this->jobs);
68
    }
69
}
70

src/Location/LocationIterator.php 1 location

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