Failed Conditions
Pull Request — master (#47)
by Florent
04:28
created

JWKSetLoader::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Bundle\JoseFramework\Routing;
15
16
use Symfony\Component\Config\Loader\LoaderInterface;
17
use Symfony\Component\Config\Loader\LoaderResolverInterface;
18
use Symfony\Component\Routing\Route;
19
use Symfony\Component\Routing\RouteCollection;
20
21
/**
22
 * Class JWKSetLoader.
23
 */
24
final class JWKSetLoader implements LoaderInterface
25
{
26
    /**
27
     * @var RouteCollection
28
     */
29
    private $routes;
30
31
    /**
32
     * JWKSetLoader Constructor.
33
     */
34
    public function __construct()
35
    {
36
        $this->routes = new RouteCollection();
37
    }
38
39
    /**
40
     * @param string $pattern
41
     * @param string $name
42
     */
43
    public function add(string $pattern, string $name)
44
    {
45
        $controller_id = sprintf('%s:getAction', $name);
46
        $defaults = ['_controller' => $controller_id];
47
        $route = new Route($pattern, $defaults);
48
        $this->routes->add(sprintf('jwkset_%s', $name), $route);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function load($resource, $type = null)
55
    {
56
        return $this->routes;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function supports($resource, $type = null)
63
    {
64
        return 'jwkset' === $type;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getResolver()
71
    {
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function setResolver(LoaderResolverInterface $resolver)
78
    {
79
    }
80
}
81