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

JWKSetManager::findJWKSet()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 9
rs 9.6667
cc 3
eloc 5
nc 3
nop 1
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\Behaviour\HasJWKManager;
15
use Jose\Finder\JWKSetFinderInterface;
16
17
/**
18
 */
19
final class JWKSetManager implements JWKSetManagerInterface
20
{
21
    use HasJWKManager;
22
23
    /**
24
     * JWKSetManager constructor.
25
     *
26
     * @param \Jose\JWKManagerInterface $jwk_manager
27
     */
28
    public function __construct(JWKManagerInterface $jwk_manager)
29
    {
30
        $this->setJWKManager($jwk_manager);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function createJWKSet(array $values = [])
37
    {
38
        $key_set = new JWKSet();
39
        if (array_key_exists('keys', $values)) {
40
            foreach ($values['keys'] as $value) {
41
                $key = $this->getJWKManager()->createJWK($value);
42
                $key_set = $key_set->addKey($key);
43
            }
44
        }
45
46
        return $key_set;
47
    }
48
}
49