Passed
Push — master ( 36f9d6...294ad3 )
by Mazarini
10:49
created

DesignController::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * Copyright (C) 2019 Mazarini <[email protected]>.
5
 * This file is part of mazarini/design.
6
 *
7
 * mazarini/design is free software: you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or (at your
10
 * option) any later version.
11
 *
12
 * mazarini/design is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15
 * more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 */
19
20
namespace Mazarini\DesignBundle\Controller;
21
22
use Mazarini\DesignBundle\Tools\Folder;
23
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
24
use Symfony\Component\HttpFoundation\Request;
25
use Symfony\Component\Routing\Annotation\Route;
26
27
class DesignController extends AbstractController
28
{
29
    /**
30
     * @Route("info", name="design_info")
31
     */
32 1
    public function info(Request $request, Folder $folder)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34 1
        $param = [];
35 1
        $param['hasLayout'] = $folder->hasLayout();
36 1
        $param['steps'] = $folder->getSteps();
37
38 1
        return $this->render('@MazariniDesign/information.html.twig', $param);
39
    }
40
41
    /**
42
     * @Route("/{debug}", name="design")
43
     */
44
    public function index(Request $request, Folder $folder, string $debug = '')
45
    {
46
        if (!$folder->hasLayout()) {
47
            return $this->information($request, $folder);
0 ignored issues
show
Bug introduced by
The method information() does not seem to exist on object<Mazarini\DesignBu...oller\DesignController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        }
49
50
        $step = $request->get('step');
51
        $steps = $folder->getSteps();
52
        if (!isset($steps[$step])) {
53
            $step = key($steps);
54
        }
55
56
        $page = $request->get('page');
57
        $pages = $folder->getPages($step);
58
        if (!isset($pages[$page])) {
59
            $page = key($pages);
60
        }
61
62
        if ('' === $debug) {
63
            $template = '@MazariniDesign/steps/'.$step.'/'.$page;
64
        } else {
65
            $template = '@MazariniDesign/debug.html.twig';
66
        }
67
68
        return $this->render($template, [
69
            'template' => $template,
70
            'current' => ['step' => $step, 'page' => $page],
71
            'steps' => $steps,
72
            'pages' => $pages,
73
        ]);
74
    }
75
}
76