TokenExtractorResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 28
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Piotzkhider\FirebaseAuthenticationModule\Extractor;
6
7
use Aura\Web\Request;
8
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Extractors;
9
use Piotzkhider\FirebaseAuthenticationModule\Exception\TokenNotFound;
10
11
class TokenExtractorResolver
12
{
13
    /**
14
     * @var TokenExtractorInterface[]
15
     */
16
    private $extractors;
17
18
    /**
19
     * @Extractors()
20
     *
21
     * @var TokenExtractorInterface[]
22
     */
23 6
    public function __construct(array $extractors)
24
    {
25 6
        $this->extractors = $extractors;
26 6
    }
27
28 2
    public function resolve(Request $request): TokenExtractorInterface
29
    {
30 2
        foreach ($this->extractors as $extractor) {
31 2
            if ($extractor->supports($request)) {
32 2
                return $extractor;
33
            }
34
        }
35
36
        throw new TokenNotFound();
37
    }
38
}
39