Completed
Push — master ( 24b9f5...f17bc4 )
by Florent
02:53
created

JWKSetFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromKeys() 0 9 2
A createFromJKU() 0 4 1
A createFromX5U() 0 4 1
A createFromValues() 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 SpomkyLabs\JoseBundle\Service;
13
14
use Jose\Factory\JWKFactory;
15
use Jose\Object\JWKSet;
16
17
final class JWKSetFactory
18
{
19
    /**
20
     * @param \Jose\Object\JWKInterface[] $keys
21
     *
22
     * @return \Jose\Object\JWKSetInterface
23
     */
24
    public static function createFromKeys(array $keys)
25
    {
26
        $jwk_set = new JWKSet();
27
        foreach ($keys as $key) {
28
            $jwk_set = $jwk_set->addKey($key);
29
        }
30
31
        return $jwk_set;
32
    }
33
34
    /**
35
     * @param string $url
36
     * @param bool   $allow_unsecured_connection
37
     *
38
     * @return \Jose\Object\JWKSetInterface
39
     */
40
    public static function createFromJKU($url, $allow_unsecured_connection = false)
41
    {
42
        return JWKFactory::createFromJKU($url, $allow_unsecured_connection);
43
    }
44
45
    /**
46
     * @param string $url
47
     * @param bool   $allow_unsecured_connection
48
     *
49
     * @return \Jose\Object\JWKSetInterface
50
     */
51
    public static function createFromX5U($url, $allow_unsecured_connection = false)
52
    {
53
        return JWKFactory::createFromX5U($url, $allow_unsecured_connection);
54
    }
55
56
    /**
57
     * @param array $values
58
     *
59
     * @return \Jose\Object\JWKSetInterface
60
     */
61
    public static function createFromValues(array $values)
62
    {
63
        return new JWKSet($values);
64
    }
65
}
66