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

JWKSetManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createJWKSet() 0 12 3
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