Failed Conditions
Pull Request — master (#82)
by Maximo
05:38
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 Phalcon\Http\RequestInterface;
9
use Gewaer\Traits\TokenTrait;
10
use Phalcon\Mvc\Micro\MiddlewareInterface;
11
use Gewaer\Exception\UnauthorizedHttpException;
12
use Phalcon\Mvc\Micro;
13
14
/**
15
 * Class AuthenticationMiddleware.
16
 *
17
 * @package Niden\Middleware
18
 */
19
abstract class TokenBase implements MiddlewareInterface
20
{
21
    use TokenTrait;
22
23
    /**
24
     * @param Request $request
25
     *
26
     * @return bool
27
     */
28 69
    protected function isValidCheck(RequestInterface $request, Micro $app): bool
29
    {
30 69
        $ignoreJwt = $request->ignoreJwt($app['router']->getMatchedRoute());
1 ignored issue
show
Bug introduced by
The method ignoreJwt() does not exist on Phalcon\Http\RequestInterface. It seems like you code against a sub-type of Phalcon\Http\RequestInterface such as Gewaer\Http\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        /** @scrutinizer ignore-call */ 
31
        $ignoreJwt = $request->ignoreJwt($app['router']->getMatchedRoute());
Loading history...
31 69
        if (!$ignoreJwt && $request->isEmptyBearerToken()) {
1 ignored issue
show
Bug introduced by
The method isEmptyBearerToken() does not exist on Phalcon\Http\RequestInterface. It seems like you code against a sub-type of Phalcon\Http\RequestInterface such as Gewaer\Http\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        if (!$ignoreJwt && $request->/** @scrutinizer ignore-call */ isEmptyBearerToken()) {
Loading history...
32
            throw new UnauthorizedHttpException('Missing Token');
33
        }
34
35 69
        return !$ignoreJwt;
36
    }
37
}
38