DefaultController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A indexAction() 0 12 2
1
<?php
2
3
namespace Kuleuven\AuthenticationBundle\Controller;
4
5
use Kuleuven\AuthenticationBundle\Service\ShibbolethServiceProvider;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
8
use Symfony\Component\Templating\EngineInterface;
9
10
class DefaultController
11
{
12
    /**
13
     * @var ShibbolethServiceProvider
14
     */
15
    protected $shibbolethServiceProvider;
16
17
    /**
18
     * @var EngineInterface
19
     */
20
    protected $templating;
21
22
    /**
23
     * @var bool
24
     */
25
    protected $debug;
26
27
    /**
28
     * @param ShibbolethServiceProvider $shibbolethServiceProvider
29
     * @param EngineInterface           $templating
30
     * @param boolean                   $debug
31
     */
32
    public function __construct(ShibbolethServiceProvider $shibbolethServiceProvider, EngineInterface $templating, $debug)
33
    {
34
        $this->shibbolethServiceProvider = $shibbolethServiceProvider;
35
        $this->templating = $templating;
36
        $this->debug = $debug;
37
    }
38
39
    /**
40
     * @return Response
41
     * @throws UnauthorizedHttpException
42
     */
43
    public function indexAction()
44
    {
45
        if (!$this->debug) {
46
            throw new UnauthorizedHttpException('Only available in debug mode.');
47
        }
48
49
        $response = new Response();
50
        $response->setContent($this->templating->render('KuleuvenAuthenticationBundle:Default:index.html.twig', [
51
            'attributes' => $this->shibbolethServiceProvider->getAttributes(),
52
        ]));
53
        return $response;
54
    }
55
}
56