Completed
Pull Request — master (#5)
by Márk
07:08
created

GuzzleMessageFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 40
ccs 0
cts 30
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createRequest() 0 15 1
A createResponse() 0 15 1
1
<?php
2
3
namespace Http\Message\MessageFactory;
4
5
use GuzzleHttp\Psr7\Request;
6
use GuzzleHttp\Psr7\Response;
7
use Http\Message\MessageFactory;
8
9
/**
10
 * Creates Guzzle messages.
11
 *
12
 * @author Márk Sági-Kazár <[email protected]>
13
 */
14
final class GuzzleMessageFactory implements MessageFactory
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function createRequest(
20
        $method,
21
        $uri,
22
        array $headers = [],
23
        $body = null,
24
        $protocolVersion = '1.1'
25
    ) {
26
        return new Request(
27
            $method,
28
            $uri,
29
            $headers,
30
            $body,
31
            $protocolVersion
32
        );
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function createResponse(
39
        $statusCode = 200,
40
        $reasonPhrase = null,
41
        array $headers = [],
42
        $body = null,
43
        $protocolVersion = '1.1'
44
    ) {
45
        return new Response(
46
            $statusCode,
47
            $headers,
48
            $body,
49
            $protocolVersion,
50
            $reasonPhrase
51
        );
52
    }
53
}
54