Test Failed
Push — main ( 109ef1...0eb966 )
by Michael
02:49
created

doDisplay()   B

Complexity

Conditions 11
Paths 12

Size

Total Lines 62
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 42
c 0
b 0
f 0
nc 12
nop 2
dl 0
loc 62
rs 7.3166

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use Twig\Environment;
4
use Twig\Error\LoaderError;
5
use Twig\Error\RuntimeError;
6
use Twig\Extension\SandboxExtension;
7
use Twig\Markup;
8
use Twig\Sandbox\SecurityError;
9
use Twig\Sandbox\SecurityNotAllowedTagError;
10
use Twig\Sandbox\SecurityNotAllowedFilterError;
11
use Twig\Sandbox\SecurityNotAllowedFunctionError;
12
use Twig\Source;
13
use Twig\Template;
14
15
/* @Menu/menu.html.twig */
16
class __TwigTemplate_ff4a6f0fd4396e829d7b7420b5f211d2bb158ee7a3e7a2adc7b223a49662ceaf extends Template
17
{
18
    private $source;
19
    private $macros = [];
20
21
    public function __construct(Environment $env)
22
    {
23
        parent::__construct($env);
24
25
        $this->source = $this->getSourceContext();
26
27
        $this->parent = false;
28
29
        // line 1
30
        $_trait_0 = $this->loadTemplate("@Menu/menu_blocks.html.twig", "@Menu/menu.html.twig", 1);
31
        if (!$_trait_0->isTraitable()) {
32
            throw new RuntimeError('Template "'."@Menu/menu_blocks.html.twig".'" cannot be used as a trait.', 1, $this->source);
33
        }
34
        $_trait_0_blocks = $_trait_0->getBlocks();
35
36
        $this->traits = $_trait_0_blocks;
37
38
        $this->blocks = array_merge(
39
            $this->traits,
40
            [
41
            ]
42
        );
43
    }
44
45
    protected function doDisplay(array $context, array $blocks = [])
46
    {
47
        $macros = $this->macros;
0 ignored issues
show
Unused Code introduced by
The assignment to $macros is dead and can be removed.
Loading history...
48
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
49
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@Menu/menu.html.twig"));
50
51
        // line 2
52
        echo "
53
<nav>
54
    ";
55
        // line 4
56
        $context['_parent'] = $context;
57
        $context['_seq'] = twig_ensure_traversable((isset($context["menus"]) || array_key_exists("menus", $context) ? $context["menus"] : (function () { throw new RuntimeError('Variable "menus" does not exist.', 4, $this->source); })()));
58
        $context['loop'] = [
59
          'parent' => $context['_parent'],
60
          'index0' => 0,
61
          'index'  => 1,
62
          'first'  => true,
63
        ];
64
        if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
65
            $length = count($context['_seq']);
66
            $context['loop']['revindex0'] = $length - 1;
67
            $context['loop']['revindex'] = $length;
68
            $context['loop']['length'] = $length;
69
            $context['loop']['last'] = 1 === $length;
70
        }
71
        foreach ($context['_seq'] as $context["_key"] => $context["entry"]) {
72
            echo " ";
73
            $this->displayBlock("menu", $context, $blocks);
74
            echo " ";
75
            ++$context['loop']['index0'];
76
            ++$context['loop']['index'];
77
            $context['loop']['first'] = false;
78
            if (isset($context['loop']['length'])) {
79
                --$context['loop']['revindex0'];
80
                --$context['loop']['revindex'];
81
                $context['loop']['last'] = 0 === $context['loop']['revindex0'];
82
            }
83
        }
84
        $_parent = $context['_parent'];
85
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['entry'], $context['_parent'], $context['loop']);
86
        $context = array_intersect_key($context, $_parent) + $_parent;
87
        // line 5
88
        echo "</nav>
89
";
90
        // line 6
91
        $context["items"] = call_user_func_array($this->env->getFunction('menu_result')->getCallable(), [$context, "main_menu"]);
0 ignored issues
show
Bug introduced by
It seems like $this->env->getFunction(...result')->getCallable() can also be of type null; however, parameter $callback of call_user_func_array() does only seem to accept callable, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

91
        $context["items"] = call_user_func_array(/** @scrutinizer ignore-type */ $this->env->getFunction('menu_result')->getCallable(), [$context, "main_menu"]);
Loading history...
92
        // line 7
93
        echo "
94
";
95
        // line 8
96
        $context['_parent'] = $context;
97
        $context['_seq'] = twig_ensure_traversable((isset($context["items"]) || array_key_exists("items", $context) ? $context["items"] : (function () { throw new RuntimeError('Variable "items" does not exist.', 8, $this->source); })()));
98
        foreach ($context['_seq'] as $context["_key"] => $context["item"]) {
99
            // line 9
100
            echo "    ";
101
        }
102
        $_parent = $context['_parent'];
103
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['item'], $context['_parent'], $context['loop']);
104
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
The assignment to $context is dead and can be removed.
Loading history...
105
        
106
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
107
108
    }
109
110
    public function getTemplateName()
111
    {
112
        return "@Menu/menu.html.twig";
113
    }
114
115
    public function isTraitable()
116
    {
117
        return false;
118
    }
119
120
    public function getDebugInfo()
121
    {
122
        return array (  100 => 9,  96 => 8,  93 => 7,  91 => 6,  88 => 5,  56 => 4,  52 => 2,  30 => 1,);
123
    }
124
125
    public function getSourceContext()
126
    {
127
        return new Source("{% use '@Menu/menu_blocks.html.twig' %}
128
129
<nav>
130
    {% for entry in menus %} {{ block('menu') }} {% endfor %}
131
</nav>
132
{% set items = menu_result('main_menu') %}
133
134
{% for item in items %}
135
    {# do whatever you want with it #}
136
{% endfor %}", "@Menu/menu.html.twig", "/Users/michaelbrauner/Bundles/Symfony/MenuBundle/src/Resources/views/menu.html.twig");
137
    }
138
}
139