SimpleFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A formatResponse() 0 7 1
A formatRequest() 0 7 1
1
<?php
2
3
namespace Http\Message\Formatter;
4
5
use Http\Message\Formatter;
6
use Psr\Http\Message\RequestInterface;
7
use Psr\Http\Message\ResponseInterface;
8
9
/**
10
 * Normalize a request or a response into a string or an array.
11
 *
12
 * @author Joel Wurtz <[email protected]>
13
 * @author Márk Sági-Kazár <[email protected]>
14
 */
15
class SimpleFormatter implements Formatter
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    public function formatRequest(RequestInterface $request)
21
    {
22 1
        return sprintf(
23 1
            '%s %s %s',
24 1
            $request->getMethod(),
25 1
            $request->getUri()->__toString(),
26 1
            $request->getProtocolVersion()
27
        );
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function formatResponse(ResponseInterface $response)
34
    {
35 1
        return sprintf(
36 1
            '%s %s %s',
37 1
            $response->getStatusCode(),
38 1
            $response->getReasonPhrase(),
39 1
            $response->getProtocolVersion()
40
        );
41
    }
42
}
43