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

TokenBase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
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 7 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Middleware;
6
7
use Gewaer\Http\Request;
8
use Gewaer\Traits\TokenTrait;
9
use Phalcon\Mvc\Micro\MiddlewareInterface;
10
use Gewaer\Exception\UnauthorizedHttpException;
11
12
/**
13
 * Class AuthenticationMiddleware.
14
 *
15
 * @package Niden\Middleware
16
 */
17
abstract class TokenBase implements MiddlewareInterface
18
{
19
    use TokenTrait;
20
21
    /**
22
     * @param Request $request
23
     *
24
     * @return bool
25
     */
26 69
    protected function isValidCheck(Request $request): bool
27
    {
28 69
        if (!$request->ignoreJwt() && $request->isEmptyBearerToken()) {
29 1
            throw new UnauthorizedHttpException('Missing Token');
30
        }
31
32 68
        return !$request->ignoreJwt();
33
    }
34
}
35