Completed
Push — 0.3.x ( 921e84...1e8c09 )
by Dmitry
14:16
created

SsoRoutesLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 2 Features 3
Metric Value
wmc 5
c 5
b 2
f 3
lcom 1
cbo 2
dl 0
loc 77
ccs 20
cts 20
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A getResolver() 0 3 1
A setResolver() 0 3 1
A __construct() 0 6 1
A load() 0 16 1
1
<?php
2
3
namespace Krtv\Bundle\SingleSignOnIdentityProviderBundle\Routing;
4
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Symfony\Component\Config\Loader\LoaderResolverInterface;
7
use Symfony\Component\Routing\Route;
8
use Symfony\Component\Routing\RouteCollection;
9
10
/**
11
 * Class SsoRoutesLoader
12
 * @package Krtv\Bundle\SingleSignOnIdentityProviderBundle\Routing
13
 */
14
class SsoRoutesLoader implements LoaderInterface
15
{
16
    /**
17
     * @var string
18
     */
19
    private $ssoHost;
20
21
    /**
22
     * @var string
23
     */
24
    private $ssoLoginPath;
25
26
    /**
27
     * @var string
28
     */
29
    private $ssoLogoutPath;
30
31
    /**
32
     * @param string $ssoHost
33
     * @param string $ssoLoginPath
34
     * @param string $ssoLogoutPath
35
     */
36 4
    public function __construct($ssoHost, $ssoLoginPath, $ssoLogoutPath)
37
    {
38 4
        $this->ssoHost = $ssoHost;
39 4
        $this->ssoLoginPath = $ssoLoginPath;
40 4
        $this->ssoLogoutPath = $ssoLogoutPath;
41 4
    }
42
43
    /**
44
     * @param string $resource
45
     * @param string $type
46
     * @return RouteCollection
47
     */
48 2
    public function load($resource, $type = null)
49
    {
50 2
        $route1 = new Route($this->ssoLoginPath, array(
51
            '_controller' => 'KrtvSingleSignOnIdentityProviderBundle:SingleSignOn:ssoLogin'
52 2
        ), array(), array(), $this->ssoHost);
53
54 2
        $route2 = new Route($this->ssoLogoutPath, array(
55
            '_controller' => 'KrtvSingleSignOnIdentityProviderBundle:SingleSignOn:ssoLogout'
56 2
        ), array(), array(), $this->ssoHost);
57
58 2
        $routes = new RouteCollection();
59 2
        $routes->add('sso_login_path', $route1);
60 2
        $routes->add('sso_logout_path', $route2);
61
62 2
        return $routes;
63
    }
64
65
    /**
66
     * @param string $resource
67
     * @param string $type
68
     * @return bool
69
     */
70 2
    public function supports($resource, $type = null)
71
    {
72 2
        return $type === 'sso';
73
    }
74
75
    /**
76
     * @return void
77
     */
78 1
    public function getResolver()
79
    {
80 1
    }
81
82
    /**
83
     * Irrelevant to us, since we don't need a resolver
84
     *
85
     * @param LoaderResolverInterface $resolver
86
     */
87 2
    public function setResolver(LoaderResolverInterface $resolver)
88
    {
89 2
    }
90
}
91