Failed Conditions
Push — master ( b8d841...bc596e )
by Florent
28:20
created

RouteLoader   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addRoute() 0 6 1
A load() 0 4 1
A supports() 0 4 1
A getResolver() 0 3 1
A setResolver() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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 OAuth2Framework\WebFingerBundle\Service;
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
class RouteLoader implements LoaderInterface
22
{
23
    /**
24
     * @var RouteCollection
25
     */
26
    private $routes;
27
28
    /**
29
     * RouteLoader constructor.
30
     */
31
    public function __construct()
32
    {
33
        $this->routes = new RouteCollection();
34
    }
35
36
    /**
37
     * @param string       $name         The name of the route
38
     * @param string       $controllerId The controller service ID
39
     * @param string       $methodName   The controller method name
40
     * @param string       $path         The path pattern to match
41
     * @param array        $defaults     An array of default parameter values
42
     * @param array        $requirements An array of requirements for parameters (regexes)
43
     * @param array        $options      An array of options
44
     * @param string       $host         The host pattern to match
45
     * @param string|array $schemes      A required URI scheme or an array of restricted schemes
46
     * @param string|array $methods      A required HTTP method or an array of restricted methods
47
     * @param string       $condition    A condition that should evaluate to true for the route to match
48
     */
49
    public function addRoute($name, $controllerId, $methodName, $path, array $defaults = [], array $requirements = [], array $options = [], $host = '', $schemes = [], $methods = [], $condition = '')
50
    {
51
        $defaults['_controller'] = \sprintf('%s:%s', $controllerId, $methodName);
52
        $route = new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
0 ignored issues
show
Bug introduced by
It seems like $schemes defined by parameter $schemes on line 49 can also be of type array; however, Symfony\Component\Routing\Route::__construct() does only seem to accept string|array<integer,string>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Bug introduced by
It seems like $methods defined by parameter $methods on line 49 can also be of type array; however, Symfony\Component\Routing\Route::__construct() does only seem to accept string|array<integer,string>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
53
        $this->routes->add(\sprintf('webfinger.%s', $name), $route);
54
    }
55
56
    public function load($resource, $type = null)
57
    {
58
        return $this->routes;
59
    }
60
61
    public function supports($resource, $type = null)
62
    {
63
        return 'webfinger' === $type;
64
    }
65
66
    public function getResolver()
67
    {
68
    }
69
70
    public function setResolver(LoaderResolverInterface $resolver)
71
    {
72
    }
73
}
74