Test Failed
Pull Request — master (#80)
by Maximo
05:30
created

TokenBase::isValidCheck()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Middleware;
6
7
use Gewaer\Http\Request;
8
use Gewaer\Traits\QueryTrait;
0 ignored issues
show
Bug introduced by
The type Gewaer\Traits\QueryTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Gewaer\Traits\ResponseTrait;
10
use Gewaer\Traits\TokenTrait;
11
use Phalcon\Mvc\Micro\MiddlewareInterface;
12
use Gewaer\Exception\NotFoundHttpException;
13
14
/**
15
 * Class AuthenticationMiddleware.
16
 *
17
 * @package Niden\Middleware
18
 */
19
abstract class TokenBase implements MiddlewareInterface
20
{
21
    use ResponseTrait;
0 ignored issues
show
Bug introduced by
The trait Gewaer\Traits\ResponseTrait requires the property $response which is not provided by Gewaer\Middleware\TokenBase.
Loading history...
22
    use TokenTrait;
23
24
    /**
25
     * @param Request $request
26
     *
27
     * @return bool
28
     */
29 69
    protected function isValidCheck(Request $request): bool
30
    {
31 69
        if (!$request->ignoreJwt() && $request->isEmptyBearerToken()) {
32 1
            throw new NotFoundHttpException('Missing Token');
33
        }
34
35
        return (
36 68
            true !== $request->ignoreJwt()
37
        );
38
    }
39
}
40