DefaultController::indexAction()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 23
rs 9.9
cc 3
nc 2
nop 0
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
8
class DefaultController extends Controller
9
{
10
    /**
11
     * @Route("/", name="homepage")
12
     */
13
    public function indexAction()
14
    {
15
        // Initialize
16
        $wsConfig = $this->container->getParameter('afsy_chat.websocket');
17
        $itsChristmas = false;
18
        $xmasLink = '';
19
20
        // Check if it's Christmas Time
21
        // Only on december and before the 26th
22
        if ('12' === date('m') && (int) date('d') < 26) {
23
            // Set Christmas
24
            $itsChristmas = true;
25
26
            // Get Christmas link
27
            $christmasLinks = $this->container->getParameter('xmas_links');
28
            $xmasLink = $christmasLinks[rand(0, \count($christmasLinks) - 1)];
29
        }
30
31
        // Render template
32
        return $this->render('default/index.html.twig', [
33
            'ws_url' => $wsConfig['host'].':'.$wsConfig['port'],
34
            'its_christmas' => $itsChristmas,
35
            'xmas_link' => $xmasLink,
36
        ]);
37
    }
38
}
39