HttplugFactory::createRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nyholm\Psr7\Factory;
6
7
use Http\Message\{MessageFactory, StreamFactory, UriFactory};
8
use Nyholm\Psr7\{Request, Response, Stream, Uri};
9
use Psr\Http\Message\UriInterface;
10
11
/**
12
 * @author Tobias Nyholm <[email protected]>
13
 * @author Martijn van der Ven <[email protected]>
14
 */
15
final class HttplugFactory implements MessageFactory, StreamFactory, UriFactory
16
{
17 1
    public function createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1')
18
    {
19 1
        return new Request($method, $uri, $headers, $body, $protocolVersion);
20
    }
21
22 1
    public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $version = '1.1')
23
    {
24 1
        return new Response((int) $statusCode, $headers, $body, $version, $reasonPhrase);
25
    }
26
27 1
    public function createStream($body = null)
28
    {
29 1
        return Stream::create($body ?? '');
30
    }
31
32 1
    public function createUri($uri = ''): UriInterface
33
    {
34 1
        if ($uri instanceof UriInterface) {
35
            return $uri;
36
        }
37
38 1
        return new Uri($uri);
39
    }
40
}
41