Psr7ResponsePrinter::toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Fitbug\Guzzle\SwaggerValidation;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * Builds a string from a PSR7 Response.
9
 */
10
class Psr7ResponsePrinter extends AbstractPsr7MesssagePrinter implements Psr7ResponsePrinterInterface
11
{
12
    /**
13
     * Generate a pretty PS7 response.
14
     *
15
     * @param ResponseInterface $response
16
     *
17
     * @return string
18
     */
19 1
    public function toString(ResponseInterface $response)
20
    {
21 1
        $string = sprintf(
22 1
            "HTTP/%s %s %s\n",
23 1
            $response->getProtocolVersion(),
24 1
            $response->getStatusCode(),
25 1
            $response->getReasonPhrase()
26
        );
27
28 1
        $string .= $this->headersAndBody($response);
29
30 1
        return $string;
31
    }
32
}
33