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

JWKSet::canKeyBeUsedWithAlgorithm()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 4
nop 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