RequestFormatter::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
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\RequestInterface;
8
9
/**
10
 * @author Emil Kilhage
11
 */
12 View Code Duplication
class RequestFormatter 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 RequestInterface $request
16
     * @return string
17
     * @throws FormatterException
18
     */
19
    public function format($request)
20
    {
21
        $body = $this->formatBody($request);
22
23
        $sections = [
24
            'Request Method' => $request->getMethod(),
25
            'Request Url' => $request->getUrl(),
26
            'Request Port' => $request->getPort(),
27
            'Request Headers' => [],
28
            'Request Body' => $body,
29
        ];
30
31
        $sections['Request Headers'] = $this->formatHeaders($request);
32
33
        $message = FormatterHelper::formatSections($sections);
34
35
        return $message;
36
    }
37
}
38