QueryParameterTokenExtractor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/**
4
 * This file is part of the BEAR.JwtAuthModule package.
5
 *
6
 * @license http://opensource.org/licenses/MIT MIT
7
 */
8
namespace BEAR\JwtAuth\Extractor;
9
10
use Aura\Web\Request;
11
use BEAR\JwtAuth\Annotation\QueryParam;
12
13
class QueryParameterTokenExtractor implements TokenExtractorInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $queryParam;
19
20
    /**
21
     * @var Request
22
     */
23
    private $request;
24
25
    /**
26
     * @QueryParam("queryParam")
27
     */
28 3
    public function __construct(string $queryParam, Request $request)
29
    {
30 3
        $this->queryParam = $queryParam;
31 3
        $this->request = $request;
32 3
    }
33
34 2
    public function extract() : string
35
    {
36 2
        return $this->request->query->get($this->queryParam) ?? '';
37
    }
38
}
39