Completed
Pull Request — master (#61)
by Tomas
03:17
created

TextApiResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Tomaj\NetteApi\Response;
4
5
use Nette\Application\UI\ITemplate;
6
use Nette\Http\IRequest;
7
use Nette\Http\IResponse;
8
use Nette\SmartObject;
9
10
class TextApiResponse implements ResponseInterface
11
{
12
    use SmartObject;
13
14
    /** @var int */
15
    private $code;
16
17
    /** @var mixed */
18
    private $data;
19
20
    /**
21
     * @param int $code
22
     * @param mixed $data
23
     */
24 3
    public function __construct(int $code, $data)
25
    {
26 3
        $this->code = $code;
27 3
        $this->data = $data;
28 3
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 3
    public function getCode(): int
34
    {
35 3
        return $this->code;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 3
    public function send(IRequest $httpRequest, IResponse $httpResponse): void
42
    {
43 3
        if ($this->data instanceof ITemplate) {
0 ignored issues
show
Bug introduced by
The class Nette\Application\UI\ITemplate does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
44
            $this->data->render();
45
        } else {
46 3
            echo $this->data;
47
        }
48 3
    }
49
}
50