StaticBufferCollection::top()   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\Collection;
6
7
use BitWasp\Buffertools\BufferInterface;
8
9
/**
10
 * @deprecated v2.0.0
11
 */
12
class StaticBufferCollection extends StaticCollection
0 ignored issues
show
Deprecated Code introduced by
The class BitWasp\Bitcoin\Collection\StaticCollection has been deprecated: v2.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

12
class StaticBufferCollection extends /** @scrutinizer ignore-deprecated */ StaticCollection
Loading history...
13
{
14
    /**
15
     * @var BufferInterface[]
16
     */
17
    protected $set = [];
18
19
    /**
20
     * @var int
21
     */
22
    protected $position = 0;
23
24
    /**
25
     * StaticBufferCollection constructor.
26
     * @param BufferInterface ...$values
27
     */
28 362
    public function __construct(BufferInterface... $values)
29
    {
30 362
        $this->set = $values;
31 362
    }
32
33
    /**
34
     * @return BufferInterface
35
     */
36 24
    public function bottom(): BufferInterface
37
    {
38 24
        return parent::bottom();
39
    }
40
41
    /**
42
     * @return BufferInterface
43
     */
44
    public function top(): BufferInterface
45
    {
46
        return parent::top();
47
    }
48
49
    /**
50
     * @return BufferInterface
51
     */
52 339
    public function current(): BufferInterface
53
    {
54 339
        return $this->set[$this->position];
55
    }
56
57
    /**
58
     * @param int $offset
59
     * @return BufferInterface
60
     */
61 264
    public function offsetGet($offset)
62
    {
63 264
        if (!array_key_exists($offset, $this->set)) {
64 2
            throw new \OutOfRangeException('No offset found');
65
        }
66
67 262
        return $this->set[$offset];
68
    }
69
}
70