Html::encode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\Output;
14
15
use Apix\View\Template,
16
    Apix\View\View,
17
    Apix\View\ViewModel,
18
    Apix\Model;
19
20
class Html extends AbstractOutput
21
{
22
23
    /**
24
     * {@inheritdoc}
25
     * @see http://www.ietf.org/rfc/rfc2854.txt
26
     */
27
    protected $content_type = 'text/html';
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function encode(array $data, $rootNode=null)
33
    {
34
        if (null !== $rootNode) {
35
            $data = array($rootNode => $data);
36
        }
37
38
        return $this->recursivelyAppend($data);
39
    }
40
41
    /**
42
     * Append the data recursively...
43
     *
44
     * @param  array  $results
45
     * @return string
46
     */
47
    protected function recursivelyAppend(array $results)
48
    {
49
        $out = '<ul>';
50
        foreach ($results as $k => $v) {
51
            $out .= "<li>$k: ";
52
            $out .= is_array($v) ? $this->recursivelyAppend($v, $k) : $v;
0 ignored issues
show
Unused Code introduced by
The call to Html::recursivelyAppend() has too many arguments starting with $k.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
            $out .= '</li>';
54
        }
55
        $out .= '</ul>';
56
57
        return $out;
58
    }
59
60
}
61