DirRadio   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 18
c 1
b 0
f 0
dl 0
loc 37
ccs 17
cts 17
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInput() 0 6 1
A getEntry() 0 7 2
A fillEntries() 0 9 2
1
<?php
2
3
namespace kalanis\kw_tree_controls\Controls;
4
5
6
use kalanis\kw_forms\Controls;
7
use kalanis\kw_templates\HtmlElement;
8
use kalanis\kw_tree\Essentials\FileNode;
9
use kalanis\kw_tree_controls\ControlNode;
10
11
12
/**
13
 * Class DirRadio
14
 * @package kalanis\kw_tree_controls\Controls
15
 */
16
class DirRadio extends ATreeControl
17
{
18
    use TRadio;
19
    use TSubEntry;
20
21
    protected string $templateLabel = '';
22
23
    /**
24
     * @param ControlNode[] $nodes
25
     * @return string
26
     */
27 1
    protected function fillEntries(array $nodes): string
28
    {
29 1
        $list = HtmlElement::init('ul');
30 1
        foreach ($nodes as $subNode) {
31 1
            $entry = $this->getEntry($subNode);
32 1
            $entry->addChild($this->fillEntries($subNode->getSubNodes()));
33 1
            $list->addChild($entry);
34
        }
35 1
        return strval($list);
36
    }
37
38 1
    protected function getEntry(ControlNode $node): HtmlElement
39
    {
40 1
        $entry = HtmlElement::init('li', ['class' => 'dir']);
41 1
        if ($childControl = $node->getControl()) {
42 1
            $entry->addChild($childControl);
43
        }
44 1
        return $entry;
45
    }
46
47 1
    protected function getInput(FileNode $node): Controls\AControl
48
    {
49 1
        $input = new Radio();
50 1
        $input->set($this->getKey(), $this->stringPath($node), $this->stringName($node));
51 1
        $this->inputs[] = $input;
52 1
        return $input;
53
    }
54
}
55