Completed
Push — master ( 24cd54...402553 )
by Billie
02:14
created

AbstractPsr7MesssagePrinter::headersAndBody()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
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
    protected function headersAndBody(MessageInterface $message)
20
    {
21
        $string = '';
22
23
        foreach ($message->getHeaders() as $name => $values) {
24
            foreach ($values as $value) {
25
                $string .= $name.': '.$value."\n";
26
            }
27
        }
28
29
        $string .= "\n";
30
        $string .= (string) $message->getBody();
31
32
        return $string;
33
    }
34
}
35