AbstractResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
1
<?php
2
3
/**
4
 * Author: Nil Portugués Calderó <[email protected]>
5
 * Date: 7/28/15
6
 * Time: 1:20 AM.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace NilPortugues\Api\Hal\Http\Response;
13
14
abstract class AbstractResponse extends \NilPortugues\Api\Http\Message\AbstractResponse
15
{
16
    /**
17
     * @var array
18
     */
19
    protected $headers = [
20
        'Content-type' => 'application/hal+json; charset=utf-8',
21
        'Cache-Control' => 'private, max-age=0, must-revalidate',
22
    ];
23
24
    /**
25
     * @param string $body
26
     */
27
    public function __construct($body)
28
    {
29
        if (is_string($body) && substr($body, 0, strlen('<?xml')) === '<?xml') {
30
            $this->headers['Content-type'] = 'application/hal+xml; charset=utf-8';
31
        }
32
33
        $this->response = self::instance($body, $this->httpCode, $this->headers);
34
    }
35
}
36