Base   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkToken() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Middleware;
6
7
use App\Exception\AuthException;
8
use Firebase\JWT\JWT;
9
10
abstract class Base
11 32
{
12
    protected function checkToken(string $token): object
13
    {
14 32
        try {
15 1
            return JWT::decode($token, $_SERVER['SECRET_KEY'], ['HS256']);
0 ignored issues
show
Unused Code introduced by
The call to Firebase\JWT\JWT::decode() has too many arguments starting with array('HS256'). ( Ignorable by Annotation )

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

15
            return JWT::/** @scrutinizer ignore-call */ decode($token, $_SERVER['SECRET_KEY'], ['HS256']);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
16 1
        } catch (\UnexpectedValueException) {
17
            throw new AuthException('Forbidden: you are not authorized.', 403);
18
        }
19
    }
20
}
21