XmlResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Furious\Psr7\Response;
6
7
use Furious\Psr7\Response;
8
use SimpleXMLElement;
9
10
class XmlResponse extends Response
11
{
12
    public function __construct($xml, int $statusCode = 200, array $headers = [], $body = null, string $version = '1.1', string $reason = null)
13
    {
14
        if ($xml instanceof SimpleXMLElement) {
15
            $body = $xml->asXML();
16
        } else {
17
            $body = (string) $xml;
18
        }
19
20
        parent::__construct($statusCode, $headers + [
21
            'Content-Type' => 'application/xml'
22
        ], $body, $version, $reason);
23
    }
24
}