Passed
Pull Request — master (#10)
by Korotkov
01:41
created

ContainerResponseTrait::getJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @copyright Copyright (c) 2017, Korotkov Danila
8
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
9
 */
10
11
namespace Rudra\Traits;
12
13
/**
14
 * Class ContainerResponseTrait
15
 *
16
 * @package Rudra
17
 */
18
trait ContainerResponseTrait
19
{
20
21
    /**
22
     * @codeCoverageIgnore
23
     * @param array $data
24
     */
25
    public function jsonResponse(array $data): void
26
    {
27
        header('Content-Type: application/json');
28
        echo $this->getJson($data);
29
    }
30
31
    /**
32
     * @param array $data
33
     * @return string
34
     */
35
    protected function getJson(array $data): string
36
    {
37
        return json_encode($data);
38
    }
39
}
40