AbstractCollectionMutator::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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