Completed
Push — master ( 6d621d...1a0788 )
by Simon
11:55
created

HeaderExtractor::getAuthorizationHeader()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: simon
5
 * Date: 22-Jul-17
6
 * Time: 14:21
7
 */
8
9
namespace Firesphere\GraphQLJWT;
10
11
use SilverStripe\Control\HTTPRequest;
12
13
class HeaderExtractor
14
{
15
16
    /**
17
     * @param HTTPRequest $request
18
     * @return array
19
     */
20
    public static function getAuthorizationHeader(HTTPRequest $request)
21
    {
22
        $authHeader = $request->getHeader('Authorization');
23
        if ($authHeader && preg_match('/Bearer\s+(.*)$/i', $authHeader, $matches)) {
24
            return $matches;
25
        }
26
        return [0, null];
27
    }
28
}
29