Failed Conditions
Push — JWKSet ( 3580c0...03e3f0 )
by Florent
02:43
created

JWKSet   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A getKeys() 0 4 1
A addKey() 0 4 1
A removeKey() 0 6 2
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 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\Object;
13
14
/**
15
 * Class JWKSet.
16
 */
17
final class JWKSet implements JWKSetInterface
18
{
19
    use BaseJWKSet;
20
21
    /**
22
     * @var array
23
     */
24
    protected $keys = [];
25
26
    public function __construct(array $keys = [])
27
    {
28
        if (array_key_exists('keys', $keys)) {
29
            foreach ($keys['keys'] as $value) {
30
                $this->addKey(new JWK($value));
31
            }
32
        }
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getKeys()
39
    {
40
        return $this->keys;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function addKey(JWKInterface $key)
47
    {
48
        $this->keys[] = $key;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function removeKey($key)
55
    {
56
        if (isset($this->keys[$key])) {
57
            unset($this->keys[$key]);
58
        }
59
    }
60
}
61