- Refractoring
This commit is contained in:
parent
b9416c580b
commit
ff4ade51fb
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user