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

Response   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getJson() 0 3 1
A jsonResponse() 0 4 1
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