Completed
Push — master ( 6e1cbd...b98f4a )
by Sebastian
02:05
created

BaseCollection::getCurrent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
1
<?php
2
namespace DjThossi\SmokeTestingPhp\Collection;
3
4
use Countable;
5
use Iterator;
6
7
abstract class BaseCollection implements Iterator, Countable
8
{
9
    /**
10
     * @var array
11
     */
12
    private $elements = [];
13
14
    abstract public function current();
15
16
    /**
17
     * @return mixed
18
     */
19
    public function key()
20
    {
21
        return key($this->elements);
22
    }
23
24
    public function next()
25
    {
26
        next($this->elements);
27
    }
28
29
    public function rewind()
30
    {
31
        reset($this->elements);
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function valid()
38
    {
39
        return array_key_exists($this->key(), $this->elements);
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function count()
46
    {
47
        return count($this->elements);
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    protected function getCurrent()
54
    {
55
        return current($this->elements);
56
    }
57
58
    /**
59
     * @param mixed $element
60
     */
61
    protected function addElement($element)
62
    {
63
        $this->elements[] = $element;
64
    }
65
}
66