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

TokenBase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValidCheck() 0 8 3
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