Skip to content

Commit 1cbc758

Browse files
committed
- add write/read Int64BE Int64LE
1 parent 2d9ab76 commit 1cbc758

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/t3ran13/ByteBuffer/ByteBuffer.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ public function writeInt32LE($value, $offset = null) {
203203
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
204204
}
205205

206+
public function writeInt64BE($value, $offset = null) {
207+
$format = 'J';
208+
$this->checkForOverSize(0xffffffffffffffff, $value);
209+
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
210+
}
211+
212+
public function writeInt64LE($value, $offset = null) {
213+
$format = 'P';
214+
$this->checkForOverSize(0xffffffffffffffff, $value);
215+
$this->insert($format, $value, $offset, $this->lengthMap->getLengthFor($format));
216+
}
217+
206218
public function read($offset, $length) {
207219
$format = 'a' . $length;
208220
return $this->extract($format, $offset, $length);
@@ -233,4 +245,14 @@ public function readInt32LE($offset) {
233245
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
234246
}
235247

248+
public function readInt64BE($offset) {
249+
$format = 'J';
250+
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
251+
}
252+
253+
public function readInt64LE($offset) {
254+
$format = 'P';
255+
return $this->extract($format, $offset, $this->lengthMap->getLengthFor($format));
256+
}
257+
236258
}

0 commit comments

Comments
 (0)