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

TokenBase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 17
ccs 4
cts 5
cp 0.8
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\TokenTrait;
9
use Phalcon\Mvc\Micro\MiddlewareInterface;
10
use Gewaer\Exception\UnauthorizedHttpException;
11
use Phalcon\Mvc\Micro;
12
13
/**
14
 * Class AuthenticationMiddleware.
15
 *
16
 * @package Niden\Middleware
17
 */
18
abstract class TokenBase implements MiddlewareInterface
19
{
20
    use TokenTrait;
21
22
    /**
23
     * @param Request $request
24
     *
25
     * @return bool
26
     */
27 69
    protected function isValidCheck(Request $request, Micro $app): bool
28
    {
29 69
        $ignoreJwt = $request->ignoreJwt($app['router']->getMatchedRoute());
30 69
        if (!$ignoreJwt && $request->isEmptyBearerToken()) {
31
            throw new UnauthorizedHttpException('Missing Token');
32
        }
33
34 69
        return !$ignoreJwt;
35
    }
36
}
37