Passed
Push — develop ( 6e1cbd...b98f4a )
by Sebastian
02:28
created

BaseCollection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 59
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
current() 0 1 ?
A key() 0 4 1
A next() 0 4 1
A rewind() 0 4 1
A valid() 0 4 1
A count() 0 4 1
A getCurrent() 0 4 1
A addElement() 0 4 1
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