Test Failed
Pull Request — master (#80)
by Maximo
05:58
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\ResponseTrait;
9
use Gewaer\Traits\TokenTrait;
10
use Phalcon\Mvc\Micro\MiddlewareInterface;
11
use Gewaer\Exception\NotFoundHttpException;
12
13
/**
14
 * Class AuthenticationMiddleware.
15
 *
16
 * @package Niden\Middleware
17
 */
18
abstract class TokenBase implements MiddlewareInterface
19
{
20
    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...
21
    use TokenTrait;
22
23
    /**
24
     * @param Request $request
25
     *
26
     * @return bool
27
     */
28 69
    protected function isValidCheck(Request $request): bool
29
    {
30 69
        if (!$request->ignoreJwt() && $request->isEmptyBearerToken()) {
31 1
            throw new NotFoundHttpException('Missing Token');
32
        }
33
34
        return (
35 68
            true !== $request->ignoreJwt()
36
        );
37
    }
38
}
39