- Refractoring

This commit is contained in:
Dave Mc Nicoll 2026-05-21 15:21:03 +00:00
parent b9416c580b
commit ff4ade51fb

View File

@ -1,7 +1,6 @@
<?php declare(strict_types=1);
namespace Dump {
use Psr\Http\Server\MiddlewareInterface,
Psr\Http\Message\ServerRequestInterface,
Psr\Http\Server\RequestHandlerInterface,
@ -28,6 +27,13 @@ namespace Dump {
{
$response = $handler->handle($request);
$stream = $this->createStream($response);
return $response->withBody($stream);
}
public function createStream(ResponseInterface $response) : Stream
{
$stream = new class("php://memory", "rw") extends Stream {
public function append_resource($resource) {
stream_copy_to_stream($resource, $this->resource);
@ -76,7 +82,7 @@ namespace Dump {
break;
}
return $response->withBody($stream);
return $stream;
}
public static function dump(...$what)