generated from Nodarx/template
feat: initial version
Signed-off-by: Sebastian Krupinski <root@LAPTOP-7DVOR6NC>
This commit was merged in pull request #1.
This commit is contained in:
43
lib/Client/Transport/Traceable/TraceableResponseStream.php
Normal file
43
lib/Client/Transport/Traceable/TraceableResponseStream.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user