ResponseFactory::createXmlResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Furious\Psr7\Factory;
6
7
use Furious\Psr7\Response;
8
use Psr\Http\Message\ResponseFactoryInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
class ResponseFactory implements ResponseFactoryInterface
12
{
13
    public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
14
    {
15
        return
16
            (new Response())
17
            ->withStatus($code, $reasonPhrase)
18
        ;
19
    }
20
21
    public function createJsonResponse(array $data, int $code = 200, string $reasonPhrase = ''): ResponseInterface
22
    {
23
        return
24
            (new Response\JsonResponse($data))
25
            ->withStatus($code, $reasonPhrase)
26
        ;
27
    }
28
29
    public function createXmlResponse($xml, int $code = 200, string $reasonPhrase = ''): ResponseInterface
30
    {
31
        return
32
            (new Response\XmlResponse($xml))
33
            ->withStatus($code, $reasonPhrase)
34
        ;
35
    }
36
37
    public function createTextResponse(string $text, int $code = 200, string $reasonPhrase = ''): ResponseInterface
38
    {
39
        return
40
            (new Response\TextResponse($text))
41
            ->withStatus($code, $reasonPhrase)
42
        ;
43
    }
44
45
    public function createHtmlResponse(string $html, int $code = 200, string $reasonPhrase = ''): ResponseInterface
46
    {
47
        return
48
            (new Response\HtmlResponse($html))
49
            ->withStatus($code, $reasonPhrase)
50
        ;
51
    }
52
53
    public function createRedirectResponse($uri, int $code = 200, string $reasonPhrase = ''): ResponseInterface
54
    {
55
        return
56
            (new Response\RedirectResponse($uri))
57
            ->withStatus($code, $reasonPhrase)
58
        ;
59
    }
60
61
    public function createEmptyResponse(): ResponseInterface
62
    {
63
        return (new Response\EmptyResponse());
64
    }
65
}