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

PublicJWKSet::__construct()   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 1
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 PublicJWKSet.
16
 */
17
final class PublicJWKSet extends BaseJWKSet implements JWKSetInterface
18
{
19
    use JWKSetPEM;
20
21
    /**
22
     * @var \Jose\Object\JWKSetInterface
23
     */
24
    private $jwkset;
25
26
    /**
27
     * PublicJWKSet constructor.
28
     *
29
     * @param \Jose\Object\JWKSetInterface $jwkset
30
     */
31
    public function __construct(JWKSetInterface $jwkset)
32
    {
33
        $this->jwkset = $jwkset;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getKeys()
40
    {
41
        $keys = [];
42
43
        foreach ($this->jwkset->getKeys() as $key) {
44
            if (in_array($key->get('kty'), ['none', 'oct'])) {
45
                continue;
46
            }
47
            $keys[] = $key->toPublic();
48
        }
49
50
        return $keys;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function addKey(JWKInterface $key)
57
    {
58
        $this->jwkset->addKey($key);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function prependKey(JWKInterface $key)
65
    {
66
        $this->jwkset->prependKey($key);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function removeKey($index)
73
    {
74
        //Not available
75
    }
76
}
77