HeaderExtractor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getToken() 0 5 2
1
<?php
2
namespace Equip\Auth\Token;
3
4
use Psr\Http\Message\ServerRequestInterface;
5
6
/**
7
 * Extracts an authentication token from a request header.
8
 */
9
class HeaderExtractor implements ExtractorInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $header;
15
16
    /**
17
     * @param string $header Name of the request header
18
     */
19 4
    public function __construct($header)
20
    {
21 4
        $this->header = (string) $header;
22 4
    }
23
24
    /**
25
     * @inheritDoc
26
     */
27 4
    public function getToken(ServerRequestInterface $request)
28
    {
29 4
        $token = current($request->getHeader($this->header));
30 4
        return $token ?: null;
31
    }
32
}
33