Passed
Push — master ( 01d7b4...8b276d )
by Steffen
01:49
created

MockRequestHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace SteffenBrand\HtmlCompressMiddleware\Test;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Psr\Http\Server\RequestHandlerInterface;
8
use Zend\Diactoros\Response;
9
10
/**
11
 * Class MockRequestHandler
12
 * @package SteffenBrand\HtmlCompressMiddleware\Test
13
 */
14
class MockRequestHandler implements RequestHandlerInterface
15
{
16
    /**
17
     * @var Response
18
     */
19
    private $response;
20
21
    public function __construct(string $contentType)
22
    {
23
        $this->response = new Response();
24
        $this->response = $this->response->withHeader('Content-Type', $contentType);
25
    }
26
27
    public function handle(ServerRequestInterface $request): ResponseInterface
28
    {
29
        $this->response = $this->response->withBody($request->getBody());
30
31
        return $this->response;
32
    }
33
}