Passed
Push — master ( 291050...8bc8e6 )
by Simon
01:52
created

HeaderExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAuthorizationHeader() 0 8 3
1
<?php
2
3
namespace Firesphere\GraphQLJWT\Helpers;
4
5
use SilverStripe\Control\HTTPRequest;
6
7
class HeaderExtractor
8
{
9
10
    /**
11
     * @param HTTPRequest $request
12
     * @return array
13
     */
14
    public static function getAuthorizationHeader(HTTPRequest $request)
15
    {
16
        $authHeader = $request->getHeader('Authorization');
17
        if ($authHeader && preg_match('/Bearer\s+(.*)$/i', $authHeader, $matches)) {
18
            return $matches;
19
        }
20
21
        return [0, null];
22
    }
23
}
24