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

HeaderExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAuthorizationHeader() 0 8 3
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