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

AbstractPsr7MesssagePrinter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A headersAndBody() 0 15 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
    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