Header::handle()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace xiaodi\JWTAuth\Handle;
6
7
class Header extends RequestToken
8
{
9
    public function handle()
10
    {
11
        $authorization = $this->app->request->header('authorization');
12
13
        if (!$authorization || strpos($authorization, 'Bearer ') !== 0) {
0 ignored issues
show
Bug introduced by
It seems like $authorization can also be of type array; however, parameter $haystack of strpos() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

13
        if (!$authorization || strpos(/** @scrutinizer ignore-type */ $authorization, 'Bearer ') !== 0) {
Loading history...
14
            return;
15
        }
16
17
        return substr($authorization, 7);
0 ignored issues
show
Bug introduced by
It seems like $authorization can also be of type array; however, parameter $string of substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

17
        return substr(/** @scrutinizer ignore-type */ $authorization, 7);
Loading history...
18
    }
19
}
20