Completed
Push — master ( c7a8ed...7c53a3 )
by Florent
08:28
created

JWKSetFactory::createFromKeys()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 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 array $values
47
     *
48
     * @return \Jose\Object\JWKSetInterface
49
     */
50
    public static function createFromValues(array $values)
51
    {
52
        return new JWKSet($values);
53
    }
54
}
55