1 | <?php |
||
9 | class Buffer implements BufferInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var int |
||
13 | */ |
||
14 | protected $size; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $buffer; |
||
20 | |||
21 | /** |
||
22 | * @param string $byteString |
||
23 | * @param null|integer $byteSize |
||
24 | * @throws \Exception |
||
25 | */ |
||
26 | 222 | public function __construct(string $byteString = '', int $byteSize = null) |
|
40 | |||
41 | /** |
||
42 | * Return a formatted version for var_dump |
||
43 | */ |
||
44 | 2 | public function __debugInfo() |
|
51 | |||
52 | /** |
||
53 | * Create a new buffer from a hex string |
||
54 | * |
||
55 | * @param string $hexString |
||
56 | * @param int|null $byteSize |
||
57 | * @return Buffer |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | 98 | public static function hex(string $hexString = '', int $byteSize = null): BufferInterface |
|
73 | |||
74 | /** |
||
75 | * @param int|string $integer |
||
76 | * @param null|int $byteSize |
||
77 | * @return Buffer |
||
78 | */ |
||
79 | 6 | public static function int($integer, $byteSize = null): BufferInterface |
|
93 | |||
94 | /** |
||
95 | * @param int $start |
||
96 | * @param integer|null $end |
||
97 | * @return BufferInterface |
||
98 | * @throws \Exception |
||
99 | */ |
||
100 | 2 | public function slice(int $start, int $end = null): BufferInterface |
|
122 | |||
123 | /** |
||
124 | * Get the size of the buffer to be returned |
||
125 | * |
||
126 | * @return int |
||
127 | */ |
||
128 | 30 | public function getSize(): int |
|
132 | |||
133 | /** |
||
134 | * Get the size of the value stored in the buffer |
||
135 | * |
||
136 | * @return int |
||
137 | */ |
||
138 | 4 | public function getInternalSize(): int |
|
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | 212 | public function getBinary(): string |
|
159 | |||
160 | /** |
||
161 | * @param bool $prefix |
||
162 | * @return string |
||
163 | */ |
||
164 | 160 | public function getHex(bool $prefix = false): string |
|
168 | |||
169 | /** |
||
170 | * @return \GMP |
||
171 | */ |
||
172 | 2 | public function getGmp(): \GMP |
|
177 | |||
178 | /** |
||
179 | * @return int|string |
||
180 | */ |
||
181 | 2 | public function getInt() |
|
185 | |||
186 | /** |
||
187 | * @return Buffer |
||
188 | */ |
||
189 | 6 | public function flip(): BufferInterface |
|
195 | |||
196 | /** |
||
197 | * @param BufferInterface $other |
||
198 | * @return bool |
||
199 | */ |
||
200 | 2 | public function equals(BufferInterface $other): bool |
|
205 | } |
||
206 |