Completed
Push — master ( bf8f23...c9e25b )
by Tomas
04:17
created

JsonApiResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 32
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCode() 0 4 1
1
<?php
2
3
namespace Tomaj\NetteApi\Response;
4
5
use Nette\Application\Responses\JsonResponse;
6
7
class JsonApiResponse extends JsonResponse
8
{
9
    /**
10
     * @var integer
11
     */
12
    private $code;
13
14
    /**
15
     * Create JsonApiResponse
16
     * This class only wrap JsonResponse from Nette and add possibility
17
     * to setup response code and automaticaly set content type
18
     *
19
     * @param integer $code
20
     * @param mixed $data
21
     * @param string $contentType
22
     */
23 12
    public function __construct($code, $data, $contentType = 'application/json; charset=utf-8')
24
    {
25 12
        parent::__construct($data, $contentType);
26 12
        $this->code = $code;
27 12
    }
28
29
    /**
30
     * Return api response http code
31
     *
32
     * @return integer
33
     */
34 12
    public function getCode()
35
    {
36 12
        return $this->code;
37
    }
38
}
39