ResponseFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createResponse() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cakasim\Payone\Sdk\Http\Factory;
6
7
use Cakasim\Payone\Sdk\Http\Message\Response;
8
use Psr\Http\Message\ResponseFactoryInterface as ResponseFactoryInterfaceAlias;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\StreamFactoryInterface;
11
12
/**
13
 * Implements the PSR-17 response factory interface.
14
 *
15
 * @author Fabian Böttcher <[email protected]>
16
 * @since 0.1.0
17
 */
18
class ResponseFactory implements ResponseFactoryInterfaceAlias
19
{
20
    /**
21
     * @var StreamFactoryInterface The stream factory used for generating response bodies.
22
     */
23
    protected $streamFactory;
24
25
    /**
26
     * Constructs the ResponseFactory.
27
     *
28
     * @param StreamFactoryInterface $streamFactory The stream factory.
29
     */
30
    public function __construct(StreamFactoryInterface $streamFactory)
31
    {
32
        $this->streamFactory = $streamFactory;
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
39
    {
40
        return new Response(
41
            $code,
42
            Response::PROTOCOL_VERSION_1_1,
43
            $this->streamFactory->createStream(),
44
            []
45
        );
46
    }
47
}
48