MagiumRecursiveContextRenderer::__invoke()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5.009

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 13
cts 14
cp 0.9286
rs 9.2408
c 0
b 0
f 0
cc 5
nc 3
nop 2
crap 5.009
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: kschr
5
 * Date: 3/20/2017
6
 * Time: 4:54 PM
7
 */
8
9
namespace Magium\Configuration\View;
10
11
use Zend\Form\Element;
12
use Zend\Form\ElementInterface;
13
use Zend\Form\View\Helper\FormElement;
14
use Zend\Form\View\Helper\FormInput;
15
use Zend\Form\View\Helper\FormSelect;
16
use Zend\View\Helper\AbstractHelper;
17
18
class MagiumRecursiveContextRenderer extends AbstractHelper
19
{
20 9
    function __invoke(array $contexts, $padding = 0)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
    {
22 9
        $output = sprintf('<ul class="nav nav-pills nav-stacked"%s>', $padding==0?' id="magium-contexts"':'');
23 9
        foreach ($contexts as $context) {
24 9
            $output .= sprintf(
25 9
                '<li
26
                            class="magium-context magium-requires-cursor"
27
                            data-context="%s"
28
                            id="magium-context-%s"
29
                            style="padding-left: %spx; "><a>%s</a>',
30 9
                    htmlspecialchars($context['id']),
31 9
                    htmlspecialchars($context['id']),
32 9
                    $padding,
33 9
                    htmlspecialchars($context['label'])
34
            );
35 9
            if (isset($context['children']) && count($context['children'])) {
36
                $output .= $this($context['children'], $padding + 10);
37
            }
38 9
            $output .= '</li>';
39
        }
40 9
        $output .= '</ul>';
41 9
        return $output;
42
    }
43
44
45
}
46