| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/share/php/PhpAmqpLib/Wire/ |
Upload File : |
<?php
namespace PhpAmqpLib\Wire;
use PhpAmqpLib\Exception\AMQPDataReadException;
class AMQPBufferReader extends AMQPReader
{
/**
* @var string
*/
private $buffer;
/**
* @var int
*/
private $length;
public function __construct(string $buffer)
{
$this->buffer = $buffer;
$this->length = mb_strlen($buffer, 'ASCII');
}
public function close(): void
{
}
/**
* Resets the object from the injected param
*
* Used to not need to create a new AMQPBufferReader instance every time.
* when we can just pass a string and reset the object state.
* NOTE: since we are working with strings we don't need to pass an AbstractIO
* or a timeout.
*
* @param string $str
*/
public function reset(string $str): void
{
$this->buffer = $str;
$this->length = mb_strlen($this->buffer, 'ASCII');
$this->offset = 0;
$this->resetCounters();
}
protected function rawread(int $n): string
{
if ($this->length < $n) {
throw new AMQPDataReadException(sprintf(
'Error reading data. Requested %s bytes while string buffer has only %s',
$n,
$this->length
));
}
$res = mb_substr($this->buffer, 0, $n, 'ASCII');
$this->buffer = mb_substr($this->buffer, $n, null, 'ASCII');
$this->length -= $n;
$this->offset += $n;
return $res;
}
}