Completed
Push — master ( abe765...8b5726 )
by Tomas
10:33
created

TextApiResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Tomaj\NetteApi\Response;
4
5
use Nette\Application\Responses\TextResponse;
6
7
class TextApiResponse extends TextResponse
8
{
9
    /**
10
     * @var integer
11
     */
12
    private $code;
13
14
    /**
15
     * Create TextApiResponse
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
     */
22 3
    public function __construct($code, $data)
23
    {
24 3
        parent::__construct($data);
25 3
        $this->code = $code;
26 3
    }
27
28
    /**
29
     * Return api response http code
30
     *
31
     * @return integer
32
     */
33 3
    public function getCode()
34
    {
35 3
        return $this->code;
36
    }
37
}
38