Failed Conditions
Pull Request — master (#82)
by Maximo
05:38
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 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
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
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