-
Notifications
You must be signed in to change notification settings - Fork 0
/
TreeUtility.php
40 lines (31 loc) · 889 Bytes
/
TreeUtility.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Filoucrackeur\StorageFrameworkManager\Utility;
class TreeUtility
{
/**
* @param array $array
* @return string
*/
public static function fromArray(array $array): string
{
if (empty($array)) {
return '';
}
$output = '<ul class="list-tree text-monospace">';
foreach ($array as $key => $value) {
$output .= '<li>';
if ($key === 'password') {
$value = '********';
}
if (is_array($value)) {
$output .= '<ul><li>' . $key . ' ' . self::fromArray($value) . '</code></li></ul>';
} else {
$output .= '<li>' . $key . ' = <code>' . $value . '</code></li>';
}
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
}