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

TokenBase::isValidCheck()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
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