PsrHttpMessageBridgePsrResponseTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toPsrResponse() 0 3 1
A __construct() 0 6 1
A fromPsrResponse() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kafkiansky\SymfonyMiddleware\Psr\Adapter;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
9
use Kafkiansky\SymfonyMiddleware\Psr\PsrResponseTransformer;
10
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
11
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
12
13
final class PsrHttpMessageBridgePsrResponseTransformer implements PsrResponseTransformer
14
{
15
    private HttpMessageFactoryInterface $httpMessageFactory;
16
    private HttpFoundationFactoryInterface $httpFoundationFactory;
17
18
    public function __construct(
19
        HttpMessageFactoryInterface $httpMessageFactory,
20
        HttpFoundationFactoryInterface $httpFoundationFactory
21
    ) {
22
        $this->httpMessageFactory = $httpMessageFactory;
23
        $this->httpFoundationFactory = $httpFoundationFactory;
24
    }
25
26
    public function toPsrResponse(SymfonyResponse $symfonyResponse): ResponseInterface
27
    {
28
        return $this->httpMessageFactory->createResponse($symfonyResponse);
29
    }
30
31
    public function fromPsrResponse(ResponseInterface $response): SymfonyResponse
32
    {
33
        return $this->httpFoundationFactory->createResponse($response);
34
    }
35
}
36