IndexController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A indexredirectAction() 0 4 1
A indexAction() 0 4 1
1
<?php
2
3
namespace Dominikzogg\EnergyCalculator\Controller;
4
5
use Saxulum\RouteController\Annotation\DI;
6
use Saxulum\RouteController\Annotation\Route;
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
use Symfony\Component\Routing\Generator\UrlGenerator;
9
10
/**
11
 * @DI(serviceIds={
12
 *      "url_generator"
13
 * })
14
 */
15
class IndexController
16
{
17
    /**
18
     * @var UrlGenerator
19
     */
20
    protected $urlGenerator;
21
22
    public function __construct(UrlGenerator $urlGenerator)
23
    {
24
        $this->urlGenerator = $urlGenerator;
25
    }
26
27
    /**
28
     * @Route("/", bind="index_redirect", method="GET")
29
     */
30
    public function indexredirectAction()
31
    {
32
        return new RedirectResponse($this->urlGenerator->generate('index'), 301);
33
    }
34
35
    /**
36
     * @Route("/{_locale}", bind="index", method="GET", asserts={"_locale"="([a-z]{2}|[a-z]{2}_[A-Z]{2})"})
37
     */
38
    public function indexAction()
39
    {
40
        return new RedirectResponse($this->urlGenerator->generate('day_list'), 301);
41
    }
42
}
43