Completed
Pull Request — master (#81)
by Michal
01:58
created

RedirectOutput::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Tomaj\NetteApi\Output;
4
5
use Nette\Application\Responses\RedirectResponse;
6
use Tomaj\NetteApi\Response\ResponseInterface;
7
use Tomaj\NetteApi\ValidationResult\ValidationResult;
8
use Tomaj\NetteApi\ValidationResult\ValidationResultInterface;
9
10
class RedirectOutput extends AbstractOutput
11
{
12
    public function validate(ResponseInterface $response): ValidationResultInterface
13
    {
14
        if (!$response instanceof RedirectResponse) {
0 ignored issues
show
Bug introduced by
The class Nette\Application\Responses\RedirectResponse 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...
15
            return new ValidationResult(ValidationResult::STATUS_ERROR);
16
        }
17
        if ($this->code !== $response->getCode()) {
18
            return new ValidationResult(ValidationResult::STATUS_ERROR, ['Response code doesn\'t match']);
19
        }
20
        return new ValidationResult(ValidationResult::STATUS_OK);
21
    }
22
}
23