ResponseFormatter::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
1
<?php
2
3
namespace Glooby\Debug\Formatter\Guzzle;
4
5
use Glooby\Debug\Exception\FormatterException;
6
use Glooby\Debug\Formatter\FormatterHelper;
7
use GuzzleHttp\Message\ResponseInterface;
8
9
/**
10
 * @author Emil Kilhage
11
 */
12 View Code Duplication
class ResponseFormatter extends AbstractMessageFormatter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @param ResponseInterface $response
16
     * @return string
17
     * @throws FormatterException
18
     */
19
    public function format($response)
20
    {
21
        $body = $this->formatBody($response);
22
23
        $sections = [
24
            'Response Status Code' => $response->getStatusCode(),
25
            'Response Protocol Version' => $response->getProtocolVersion(),
26
            'Response Reason Phrase' => $response->getReasonPhrase(),
27
            'Response Effective Url' => $response->getEffectiveUrl(),
28
            'Response Headers' => [],
29
            'Response Body' => $body,
30
        ];
31
32
        $sections['Response Headers'] = $this->formatHeaders($response);
33
34
        $message = FormatterHelper::formatSections($sections);
35
36
        return $message;
37
    }
38
}
39