Passed
Push — master ( b28623...b691b7 )
by Sebastian
04:23
created

VariableInfo_Renderer_String_Array   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 2
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _render() 0 5 1
A traverseArray() 0 17 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
class VariableInfo_Renderer_String_Array extends VariableInfo_Renderer_String
8
{
9
    protected function _render()
10
    {
11
        $result = $this->traverseArray($this->value);
12
        
13
        return print_r($result, true);
14
    }
15
    
16
    protected function traverseArray(array $array, int $level=0) : array
17
    {
18
        $result = array();
19
        
20
        foreach($array as $key => $val)
21
        {
22
            if(is_array($val))
23
            {
24
                $result[$key] = $this->traverseArray($val, ($level+1));
25
            }
26
            else
27
            {
28
                $result[$key] = parseVariable($val)->toString();
29
            }
30
        }
31
        
32
        return $result;
33
    }
34
}
35