Collection   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 79
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 3 1
A from() 0 3 1
A count() 0 3 1
A rewind() 0 3 1
A next() 0 3 1
A valid() 0 3 1
A jsonSerialize() 0 3 1
A __construct() 0 3 1
A key() 0 3 1
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Utils;
4
5
abstract class Collection implements \Iterator, \Countable, \JsonSerializable
6
{
7
    /**
8
     * @var array
9
     */
10
    private $items;
11
12
    /**
13
     * @param array $items
14
     */
15
    final protected function __construct(array $items)
16
    {
17
        $this->items = $items;
18
    }
19
20
    /**
21
     * @return mixed
22
     */
23
    public function current()
24
    {
25
        return \current($this->items);
26
    }
27
28
    /**
29
     * @return void
30
     */
31
    public function next()
32
    {
33
        \next($this->items);
34
    }
35
36
    /**
37
     * @return int|mixed|string|null
38
     */
39
    public function key()
40
    {
41
        return \key($this->items);
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function valid()
48
    {
49
        return \array_key_exists($this->key(), $this->items);
50
    }
51
52
    /**
53
     * @return void
54
     */
55
    public function rewind()
56
    {
57
        \reset($this->items);
58
    }
59
60
    /**
61
     * @return int|void
62
     */
63
    public function count()
64
    {
65
        return \count($this->items);
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function jsonSerialize()
72
    {
73
        return $this->items;
74
    }
75
76
    /**
77
     * @param array $items
78
     *
79
     * @return static
80
     */
81
    public static function from(array $items)
82
    {
83
        return new static($items);
84
    }
85
}
86