AbstractPsr7MesssagePrinter::headersAndBody()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Fitbug\Guzzle\SwaggerValidation;
4
5
use Psr\Http\Message\MessageInterface;
6
7
/**
8
 * Print a request or response PSR7 Message.
9
 */
10
abstract class AbstractPsr7MesssagePrinter
11
{
12
    /**
13
     * Generate the headers and body part of the message.
14
     *
15
     * @param MessageInterface $message
16
     *
17
     * @return string
18
     */
19 2
    protected function headersAndBody(MessageInterface $message)
20
    {
21 2
        $string = '';
22
23 2
        foreach ($message->getHeaders() as $name => $values) {
24 2
            foreach ($values as $value) {
25 2
                $string .= $name.': '.$value."\n";
26
            }
27
        }
28
29 2
        $string .= "\n";
30 2
        $string .= (string) $message->getBody();
31
32 2
        return $string;
33
    }
34
}
35