Passed
Pull Request — master (#42)
by Korotkov
02:47
created

Response::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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Jagepard <[email protected]">
7
 * @copyright Copyright (c) 2019, Jagepard
8
 * @license   https://mit-license.org/ MIT
9
 */
10
11
namespace Rudra\Container;
12
13
use Rudra\Container\Interfaces\ResponseInterface;
14
15
class Response implements ResponseInterface
16
{
17
    /**
18
     * @codeCoverageIgnore
19
     * @param array $data
20
     */
21
    public function jsonResponse(array $data): void
22
    {
23
        header('Content-Type: application/json');
24
        print $this->getJson($data);
25
    }
26
27
    /**
28
     * @param array $data
29
     * @return string
30
     */
31
    private function getJson(array $data): string
32
    {
33
        return json_encode($data);
34
    }
35
}
36