Failed Conditions
Push — master ( 7ceb40...229c6c )
by Florent
12:35 queued 08:11
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
 * Class JKUJWKSet.
19
 */
20
final class X5UJWKSet extends DownloadedJWKSet
21
{
22
    /**
23
     * @return \Jose\Object\JWKInterface[]
24
     */
25
    public function getKeys()
26
    {
27
        $content = json_decode($this->getContent(), true);
28
        Assertion::isArray($content, 'Invalid content.');
29
        $jwkset = new JWKSet();
30
        foreach ($content as $kid => $cert) {
31
            $jwk = KeyConverter::loadKeyFromCertificate($cert);
32
            Assertion::notEmpty($jwk, 'Invalid content.');
33
            if (is_string($kid)) {
34
                $jwk['kid'] = $kid;
35
            }
36
            $jwkset->addKey(new JWK($jwk));
37
        }
38
39
        return $jwkset->getKeys();
40
    }
41
}
42