31 lines
714 B
PHP
31 lines
714 B
PHP
<?php
|
|
namespace FWIF;
|
|
|
|
class FWIFDecodeStream {
|
|
private string $body;
|
|
private int $length;
|
|
private int $position = 0;
|
|
|
|
public function __construct(string $body) {
|
|
$this->body = $body;
|
|
$this->length = strlen($body);
|
|
}
|
|
|
|
public function getLength(): int {
|
|
return $this->length;
|
|
}
|
|
|
|
public function getPosition(): int {
|
|
return $this->position;
|
|
}
|
|
|
|
public function stepBack(): void {
|
|
$this->position = max(0, $this->position - 1);
|
|
}
|
|
|
|
public function readByte(): int {
|
|
if($this->position + 1 >= $this->length)
|
|
return 0xFF;
|
|
return ord($this->body[$this->position++]);
|
|
}
|
|
}
|