Failed Conditions
Pull Request — master (#82)
by Maximo
07:02
created

library/Middleware/TokenBase.php (2 issues)

Labels
Severity
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
use Phalcon\Http\RequestInterface;
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(RequestInterface $request, Micro $app): bool
28
    {
29 69
        $ignoreJwt = $request->ignoreJwt($app['router']->getMatchedRoute());
1 ignored issue
show
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

29
        /** @scrutinizer ignore-call */ 
30
        $ignoreJwt = $request->ignoreJwt($app['router']->getMatchedRoute());
Loading history...
30 69
        if (!$ignoreJwt && $request->isEmptyBearerToken()) {
1 ignored issue
show
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

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