-
Notifications
You must be signed in to change notification settings - Fork 446
Expand file tree
/
Copy pathStaticBufferCollection.php
More file actions
66 lines (55 loc) · 1.19 KB
/
StaticBufferCollection.php
File metadata and controls
66 lines (55 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace BitWasp\Bitcoin\Collection;
use BitWasp\Buffertools\BufferInterface;
class StaticBufferCollection extends StaticCollection
{
/**
* @var BufferInterface[]
*/
protected $set = [];
/**
* @var int
*/
protected $position = 0;
/**
* StaticBufferCollection constructor.
* @param BufferInterface ...$values
*/
public function __construct(BufferInterface... $values)
{
$this->set = $values;
}
/**
* @return BufferInterface
*/
public function bottom(): BufferInterface
{
return parent::bottom();
}
/**
* @return BufferInterface
*/
public function top(): BufferInterface
{
return parent::top();
}
/**
* @return BufferInterface
*/
public function current(): BufferInterface
{
return $this->set[$this->position];
}
/**
* @param int $offset
* @return BufferInterface
*/
public function offsetGet($offset)
{
if (!array_key_exists($offset, $this->set)) {
throw new \OutOfRangeException('No offset found');
}
return $this->set[$offset];
}
}