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

TreeUtility   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 35
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 28 5
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