Completed
Push — master ( 717772...a6c217 )
by Michal
03:16 queued 01:40
created

TextApiResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 40
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCode() 0 4 1
A send() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tomaj\NetteApi\Response;
6
7
use Nette\Application\UI\ITemplate;
8
use Nette\Http\IRequest;
9
use Nette\Http\IResponse;
10
use Nette\SmartObject;
11
12
class TextApiResponse implements ResponseInterface
13
{
14
    use SmartObject;
15
16
    /** @var int */
17
    private $code;
18
19
    /** @var mixed */
20
    private $data;
21
22
    /**
23
     * @param int $code
24
     * @param mixed $data
25
     */
26 6
    public function __construct(int $code, $data)
27
    {
28 6
        $this->code = $code;
29 6
        $this->data = $data;
30 6
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 3
    public function getCode(): int
36
    {
37 3
        return $this->code;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 3
    public function send(IRequest $httpRequest, IResponse $httpResponse): void
44
    {
45 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...
46
            $this->data->render();
47
        } else {
48 3
            echo $this->data;
49
        }
50 3
    }
51
}
52