Files
provider_imap/lib/Client/Transport/Traceable/TraceableResponseStream.php
2026-03-28 12:43:42 -04:00

43 lines
872 B
PHP

<?php
declare(strict_types=1);
namespace Gricob\IMAP\Transport\Traceable;
use Gricob\IMAP\Transport\ResponseStream;
use Psr\Log\LoggerInterface;
final readonly class TraceableResponseStream implements ResponseStream
{
public function __construct(
private ResponseStream $responseStream,
private LoggerInterface $logger,
) {
}
public function read(int $bytes): string
{
$data = $this->responseStream->read($bytes);
$this->debug($data);
return $data;
}
public function readLine(): string
{
$line = $this->responseStream->readLine();
$this->debug($line);
return $line;
}
private function debug(string $data): void
{
// $data = addslashes($data);
// $data = str_replace("\r\n", "\\r\\n", $data);
$this->logger->debug($data);
}
}