Completed
Push — master ( 75e1cb...c3c281 )
by Gabriel
02:18
created

Collection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Waredesk;
4
5
use Iterator;
6
use Countable;
7
8
class Collection implements Iterator, Countable
9
{
10
    protected $items;
11
    protected $key;
12
13
    public function __construct(array $items = [])
14
    {
15
        $this->items = $items;
16
    }
17
18
    public function count()
19
    {
20
        return count($this->items);
21
    }
22
23
    public function current()
24
    {
25
        return current($this->items);
26
    }
27
28
    public function next()
29
    {
30
        return next($this->items);
31
    }
32
33
    public function key()
34
    {
35
        return key($this->items);
36
    }
37
38
    public function valid()
39
    {
40
        $key = key($this->items);
41
        return ($key !== null && $key !== false);
42
    }
43
44
    public function rewind()
45
    {
46
        reset($this->items);
47
    }
48
}
49