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

MutableCollection   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 113
rs 10
ccs 10
cts 30
cp 0.3333

12 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A isNull() 0 4 1
A count() 0 4 1
A rewind() 0 4 1
A current() 0 4 1
A key() 0 4 1
A next() 0 4 1
A valid() 0 4 1
A offsetExists() 0 4 1
A offsetUnset() 0 8 2
A offsetGet() 0 7 2
A offsetSet() 0 4 1
1
<?php
2
3
namespace BitWasp\Bitcoin\Collection;
4
5
abstract class MutableCollection implements CollectionInterface
6
{
7
    /**
8
     * @var \SplFixedArray
9
     */
10
    protected $set;
11
12
    /**
13
     * @return array
14
     */
15
    public function all()
16
    {
17
        return $this->set->toArray();
18
    }
19
20
    /**
21
     * @return bool
22
     */
23
    public function isNull()
24
    {
25
        return count($this->set) === 0;
26
    }
27
28
    /**
29
     * @return int
30
     */
31 94
    public function count()
32
    {
33 94
        return $this->set->count();
34 94
    }
35
36
    /**
37
     *
38
     */
39
    public function rewind()
40
    {
41
        $this->set->rewind();
42
    }
43
44
    /**
45
     * @return mixed
46
     */
47 12
    public function current()
48
    {
49 12
        return $this->set->current();
50
    }
51
52
    /**
53
     * @return int
54
     */
55 94
    public function key()
56
    {
57 94
        return $this->set->key();
58 94
    }
59
60
    /**
61
     *
62
     */
63 94
    public function next()
64
    {
65 94
        $this->set->next();
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function valid()
72
    {
73
        return $this->set->valid();
74
    }
75
76
    /**
77
     * @param int $offset
78
     * @return bool
79
     */
80
    public function offsetExists($offset)
81
    {
82
        return $this->set->offsetExists($offset);
83
    }
84
85
    /**
86
     * @param int $offset
87
     */
88
    public function offsetUnset($offset)
89
    {
90
        if (!$this->offsetExists($offset)) {
91
            throw new \InvalidArgumentException('Offset does not exist');
92
        }
93
94
        $this->set->offsetUnset($offset);
95
    }
96
97
    /**
98
     * @param int $offset
99
     * @return mixed
100
     */
101
    public function offsetGet($offset)
102
    {
103
        if (!$this->set->offsetExists($offset)) {
104
            throw new \OutOfRangeException('Nothing found at this offset');
105
        }
106
        return $this->set->offsetGet($offset);
107
    }
108
109
    /**
110
     * @param int $offset
111
     * @param mixed $value
112
     */
113
    public function offsetSet($offset, $value)
114
    {
115
        $this->set->offsetSet($offset, $value);
116
    }
117
}
118