for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace PBurggraf\BinaryUtilities\DataType;
use PBurggraf\BinaryUtilities\Exception\EndOfFileReachedException;
/**
* @author Philip Burggraf <[email protected]>
*/
class Byte extends AbstractDataType
{
* @throws EndOfFileReachedException
*
* @return array
public function read(): array
$this->assertNotEndOfFile();
return [$this->getByte($this->offset++)];
}
* @param int $length
public function readArray(int $length): array
$buffer = [];
for ($iterator = 0; $iterator < $length; ++$iterator) {
$buffer[] = $this->getByte($this->offset++);
return $buffer;
* @param int $data
public function write(int $data): void
$this->setByte($this->offset++, $data);
* @param array $data
public function writeArray(array $data): void
$dataLength = count($data);
$startBytePosition = $this->offset;
for ($i = $startBytePosition; $i <= $startBytePosition - 1 + $dataLength; ++$i) {
$this->setByte($this->offset++, $data[$i - $startBytePosition]);
* @return string
public function newContent(): string
return $this->content;
* @return int
public function newOffset(): int
return $this->offset;