JsonResponse::setContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Faulancer\Http;
4
5
/**
6
 * Class JsonResponse
7
 *
8
 * @package Faulancer\Http
9
 * @author  Florian Knapp <[email protected]>
10
 */
11
class JsonResponse extends Response
12
{
13
14
    /** @var array */
15
    protected $content = [];
16
17
    /**
18
     * Set content
19
     *
20
     * @param array $content
21
     *
22
     * @return self
23
     */
24
    public function setContent($content = [])
25
    {
26
        $this->setResponseHeader(['Content-Type' => 'application/json']);
27
28
        $this->content = json_encode($content);
29
        return $this;
30
    }
31
32
}