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 | 218 | 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 | 94 | public static function hex(string $hexString = '', int $byteSize = null): BufferInterface |
|
69 | |||
70 | /** |
||
71 | * @param int|string $integer |
||
72 | * @param null|int $byteSize |
||
73 | * @return Buffer |
||
74 | */ |
||
75 | 6 | public static function int($integer, $byteSize = null): BufferInterface |
|
80 | |||
81 | 6 | /** |
|
82 | 6 | * @param \GMP $gmp |
|
83 | 4 | * @return Buffer |
|
84 | * @throws \Exception |
||
85 | */ |
||
86 | 6 | public static function gmp(\GMP $gmp, $byteSize = null): BufferInterface |
|
100 | |||
101 | /** |
||
102 | 2 | * @param int $start |
|
103 | * @param integer|null $end |
||
104 | * @return BufferInterface |
||
105 | * @throws \Exception |
||
106 | 2 | */ |
|
107 | public function slice(int $start, int $end = null): BufferInterface |
||
129 | |||
130 | /** |
||
131 | * Get the size of the buffer to be returned |
||
132 | * |
||
133 | * @return int |
||
134 | 2 | */ |
|
135 | public function getSize(): int |
||
139 | |||
140 | /** |
||
141 | * Get the size of the value stored in the buffer |
||
142 | 208 | * |
|
143 | * @return int |
||
144 | */ |
||
145 | 208 | public function getInternalSize(): int |
|
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | 206 | public function getBinary(): string |
|
166 | |||
167 | 2 | /** |
|
168 | * @return string |
||
169 | 2 | */ |
|
170 | 2 | public function getHex(): string |
|
174 | |||
175 | /** |
||
176 | 2 | * @return \GMP |
|
177 | */ |
||
178 | 2 | public function getGmp(): \GMP |
|
183 | |||
184 | 6 | /** |
|
185 | * @return int|string |
||
186 | */ |
||
187 | 6 | public function getInt() |
|
191 | |||
192 | /** |
||
193 | * @return Buffer |
||
194 | */ |
||
195 | 2 | public function flip(): BufferInterface |
|
201 | |||
202 | /** |
||
203 | * @param BufferInterface $other |
||
204 | * @return bool |
||
205 | */ |
||
206 | public function equals(BufferInterface $other): bool |
||
211 | } |
||
212 |