Completed
Pull Request — master (#591)
by thomas
30:58
created

StaticBufferCollection::bottom()   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 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Collection;
6
7
use BitWasp\Buffertools\BufferInterface;
8
9
class StaticBufferCollection extends StaticCollection
10
{
11
    /**
12
     * @var BufferInterface[]
13
     */
14
    protected $set = [];
15
16
    /**
17
     * @var int
18
     */
19
    protected $position = 0;
20
21
    /**
22
     * StaticBufferCollection constructor.
23
     * @param BufferInterface[] $values
24
     */
25 214
    public function __construct(BufferInterface... $values)
26
    {
27 214
        $this->set = $values;
0 ignored issues
show
Documentation Bug introduced by
It seems like $values of type array<integer,array<inte...ools\BufferInterface>>> is incompatible with the declared type array<integer,object<Bit...tools\BufferInterface>> of property $set.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28 214
    }
29
30
    /**
31
     * @return BufferInterface
32
     */
33 17
    public function bottom(): BufferInterface
34
    {
35 17
        return parent::bottom();
36
    }
37
38
    /**
39
     * @return BufferInterface
40
     */
41
    public function top(): BufferInterface
42
    {
43
        return parent::top();
44
    }
45
46
    /**
47
     * @return BufferInterface
48
     */
49 132
    public function current(): BufferInterface
50
    {
51 132
        return $this->set[$this->position];
52
    }
53
54
    /**
55
     * @param int $offset
56
     * @return BufferInterface
57
     */
58 144
    public function offsetGet($offset)
59
    {
60 144
        if (!array_key_exists($offset, $this->set)) {
61 2
            throw new \OutOfRangeException('No offset found');
62
        }
63
64 142
        return $this->set[$offset];
65
    }
66
}
67