Completed
Pull Request — develop (#61)
by Kevin
09:23
created

MagiumRecursiveContextRenderer::__invoke()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5.0113

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 12
cts 13
cp 0.9231
rs 8.5906
c 0
b 0
f 0
cc 5
eloc 14
nc 3
nop 2
crap 5.0113
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 8
    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 8
        $output = sprintf('<ul class="nav nav-pills nav-stacked"%s>', $padding==0?' id="magium-contexts"':'');
23 8
        foreach ($contexts as $context) {
24 8
            $output .= sprintf(
25
                '<li
26
                            class="magium-context magium-requires-cursor"
27
                            data-context="%s"
28
                            id="magium-context-%s"
29 8
                            style="padding-left: %spx; "><a>%s</a>',
30 8
                    htmlspecialchars($context['id']),
31 8
                    htmlspecialchars($context['id']),
32
                    $padding,
33 8
                    htmlspecialchars($context['label'])
34
            );
35 8
            if (isset($context['children']) && count($context['children'])) {
36
                $output .= $this($context['children'], $padding + 10);
37
            }
38 8
            $output .= '</li>';
39
        }
40 8
        $output .= '</ul>';
41 8
        return $output;
42
    }
43
44
45
}
46