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

HeaderExtractor::getAuthorizationHeader()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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