Completed
Push — master ( 8feb15...b9cea8 )
by Florent
02:52
created

JWKFinderManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addJWKFinder() 0 4 1
A findJWK() 0 15 4
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2015 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose;
13
14
use Jose\Finder\JWKFinderInterface;
15
16
/**
17
 */
18
final class JWKFinderManager implements JWKFinderManagerInterface
19
{
20
    /**
21
     * @var \Jose\Finder\JWKFinderInterface[]
22
     */
23
    private $finders = [];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function addJWKFinder(JWKFinderInterface $finder)
29
    {
30
        $this->finders[] = $finder;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function findJWK(array $header)
37
    {
38
        $keys = ['keys' => []];
39
        foreach ($this->finders as $finder) {
40
            $result = $finder->findJWK($header);
41
            if (is_array($result)) {
42
                if (array_key_exists('keys', $result)) {
43
                    $keys['keys'] = array_merge($result['keys'], $keys['keys']);
44
                } else {
45
                    $keys['keys'][] = $result;
46
                }
47
            }
48
        }
49
        return $keys;
50
    }
51
}
52