Test Failed
Push — master ( 3db309...4f4bbc )
by Philippe
01:47
created

TreeUtility::fromArray()   A

Complexity

Conditions 5
Paths 6

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5.009

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 13
cts 14
cp 0.9286
rs 9.1608
c 0
b 0
f 0
cc 5
nc 6
nop 1
crap 5.009
1
<?php
2
declare(strict_types=1);
3
4
namespace Filoucrackeur\StorageFrameworkManager\Utility;
5
6
class TreeUtility
7
{
8
    /**
9
     * @param array $array
10
     * @return string
11
     */
12 2
    public static function fromArray(array $array): string
13
    {
14 2
        if (empty($array)) {
15
            return '';
16
        }
17
18 2
        $output = '<ul class="list-tree text-monospace">';
19
20 2
        foreach ($array as $key => $value) {
21 2
            $output .= '<li>';
22
23 2
            if ($key === 'password') {
24 2
                $value = '********';
25
            }
26
27 2
            if (is_array($value)) {
28 2
                $output .= '<ul><li>' . $key . ' ' . self::fromArray($value) . '</code></li></ul>';
29
            } else {
30 2
                $output .= '<li>' . $key . ' = <code>' . $value . '</code></li>';
31
            }
32
33 2
            $output .= '</li>';
34
        }
35
36 2
        $output .= '</ul>';
37
38 2
        return $output;
39
    }
40
}
41