Passed
Push — master ( 943848...db2d78 )
by Sebastian
04:16
created

VariableInfo_Renderer_String_Callable::_render()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 23
rs 9.6111
cc 5
nc 5
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
use Closure;
8
9
class VariableInfo_Renderer_String_Callable extends VariableInfo_Renderer_String
10
{
11
    protected function _render()
12
    {
13
        $string = '';
14
15
        // Simple function call
16
        if(is_string($this->value))
17
        {
18
            return $this->value.'()';
19
        }
20
21
        if(is_array($this->value)) {
22
            return $this->renderArray();
23
        }
24
25
        if($this->value instanceof NamedClosure) {
26
            return 'Closure:'.$this->value->getOrigin();
27
        }
28
29
        if($this->value instanceof Closure) {
30
            return 'Closure';
31
        }
32
33
        return $string;
34
    }
35
36
    private function renderArray() : string
37
    {
38
        $string = '';
39
40
        if (is_string($this->value[0])) {
41
            $string .= $this->value[0] . '::';
42
        } else {
43
            $string .= get_class($this->value[0]) . '->';
44
        }
45
46
        $string .= $this->value[1].'()';
47
48
        return $string;
49
    }
50
}
51