Failed Conditions
Push — UrlJWKSet ( 7ceb40...22eb3b )
by Florent
02:53
created

X5UJWKSet   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 22
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getKeys() 0 16 3
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
use Assert\Assertion;
15
use Jose\KeyConverter\KeyConverter;
16
17
18
/**
19
 * Class JKUJWKSet
20
 */
21
final class X5UJWKSet extends DownloadedJWKSet
22
{
23
    /**
24
     * @return \Jose\Object\JWKInterface[]
25
     */
26
    public function getKeys()
27
    {
28
        $content = json_decode($this->getContent(), true);
29
        Assertion::isArray($content, 'Invalid content.');
30
        $jwkset = new JWKSet();
31
        foreach ($content as $kid => $cert) {
32
            $jwk = KeyConverter::loadKeyFromCertificate($cert);
33
            Assertion::notEmpty($jwk, 'Invalid content.');
34
            if (is_string($kid)) {
35
                $jwk['kid'] = $kid;
36
            }
37
            $jwkset->addKey(new JWK($jwk));
38
        }
39
40
        return $jwkset->getKeys();
41
    }
42
}
43