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

PublicJWKSet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 52
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getKeys() 0 13 3
A addKey() 0 4 1
A removeKey() 0 4 1
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 PublicJWKSet
16
 */
17
final class PublicJWKSet implements JWKSetInterface
18
{
19
    use BaseJWKSet;
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 removeKey($index)
65
    {
66
        //Not available
67
    }
68
}
69