Completed
Pull Request — master (#244)
by thomas
201:55 queued 131:14
created

StaticCollection::isNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Collection;
4
5
abstract class StaticCollection implements CollectionInterface
6
{
7
    /**
8
     * @var \SplFixedArray
9
     */
10
    protected $set;
11
12
    /**
13
     * @return array
14
     */
15 358
    public function all()
16
    {
17 358
        return $this->set->toArray();
18
    }
19
20
    /**
21
     * @return bool
22
     */
23 272
    public function isNull()
24
    {
25 272
        return count($this->set) === 0;
26
    }
27
28
    /**
29
     * @return int
30
     */
31 120
    public function count()
32
    {
33 120
        return $this->set->count();
34 120
    }
35
36
    /**
37
     *
38
     */
39 6
    public function rewind()
40
    {
41 6
        $this->set->rewind();
42
    }
43
44
    /**
45
     * @return mixed
46
     */
47 96
    public function current()
48
    {
49 96
        return $this->set->current();
50
    }
51
52
    /**
53
     * @return int
54
     */
55 120
    public function key()
56
    {
57 120
        return $this->set->key();
58 120
    }
59
60
    /**
61
     *
62
     */
63 120
    public function next()
64
    {
65 120
        $this->set->next();
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function valid()
72 6
    {
73
        return $this->set->valid();
74 6
    }
75
76
    /**
77
     * @param int $offset
78
     * @return bool
79
     */
80 6
    public function offsetExists($offset)
81
    {
82 6
        return $this->set->offsetExists($offset);
83
    }
84
85
    /**
86
     * @param int $offset
87
     */
88
    public function offsetUnset($offset)
89 24
    {
90
        throw new \RuntimeException('Cannot unset from a Static Collection');
91 24
    }
92 12
93
    /**
94 12
     * @param int $offset
95
     * @return mixed
96
     */
97
    public function offsetGet($offset)
98
    {
99
        if (!$this->set->offsetExists($offset)) {
100
            throw new \OutOfRangeException('Nothing found at this offset');
101 12
        }
102
        return $this->set->offsetGet($offset);
103 12
    }
104
105
    /**
106
     * @param int $offset
107
     * @param mixed $value
108
     */
109
    public function offsetSet($offset, $value)
110
    {
111
        throw new \RuntimeException('Cannot add to a Static Collection');
112
    }
113
}
114