Failed Conditions
Pull Request — master (#292)
by
unknown
14:43 queued 03:35
created

JWKSet::getKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2017 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 extends BaseJWKSet implements JWKSetInterface
18
{
19
    use JWKSetPEM;
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 prependKey(JWKInterface $key)
55
    {
56
        array_unshift($this->keys, $key);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function removeKey($key)
63
    {
64
        if (array_key_exists($key, $this->keys)) {
65
            unset($this->keys[$key]);
66
        }
67
    }
68
}
69