JsonResponse::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Preetender\Routing\Response;
4
5
/**
6
 * Class JsonResponse
7
 * @package Preetender\Routing\Response
8
 */
9
final class JsonResponse extends BaseResponse
10
{
11
    /**
12
     * Inform headers for json requests
13
     *
14
     * @var array
15
     */
16
    protected $headers = [
17
        'Content-type' => 'application/json'
18
    ];
19
20
    /**
21
     * Format and return to requester
22
     *
23
     * @return mixed
24
     */
25
    public function render()
26
    {
27
        $this->response->setContent(json_encode($this->wrapped->render()));
28
        $this->response->headers->add($this->headers);
29
        $this->response->prepare($this->request);
30
        $this->response->send();
31
    }
32
}