Completed
Push — master ( aa4cd3...2b0512 )
by yoshihiro
01:23
created

IDTokenExtractorResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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\IDTokenExtractor;
6
7
use Aura\Web\Request;
8
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Extractors;
9
use Piotzkhider\FirebaseAuthenticationModule\Exception\IDTokenNotFound;
10
11
class IDTokenExtractorResolver
12
{
13
    /**
14
     * @var IDTokenExtractorInterface[]
15
     */
16
    private $extractors;
17
18
    /**
19
     * @Extractors()
20
     *
21
     * @param IDTokenExtractorInterface[] $extractors
22
     */
23 5
    public function __construct(array $extractors)
24
    {
25 5
        $this->extractors = $extractors;
26 5
    }
27
28 4
    public function resolve(Request $request): IDTokenExtractorInterface
29
    {
30 4
        foreach ($this->extractors as $extractor) {
31 3
            if ($extractor->supports($request)) {
32 3
                return $extractor;
33
            }
34
        }
35
36 1
        throw new IDTokenNotFound();
37
    }
38
}
39