ClosurePlugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderObject() 0 24 4
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2013 Jonathan Vollebregt ([email protected]), Rokas Šleinius ([email protected])
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
 * this software and associated documentation files (the "Software"), to deal in
10
 * the Software without restriction, including without limitation the rights to
11
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
 * the Software, and to permit persons to whom the Software is furnished to do so,
13
 * subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in all
16
 * copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 */
25
26
namespace Kint\Renderer\Rich;
27
28
use Kint\Kint;
29
use Kint\Object\BasicObject;
30
use Kint\Object\ClosureObject;
31
32
class ClosurePlugin extends Plugin implements ObjectPluginInterface
33
{
34
    public function renderObject(BasicObject $o)
35
    {
36
        $children = $this->renderer->renderChildren($o);
37
38
        if (!($o instanceof ClosureObject)) {
39
            $header = $this->renderer->renderHeader($o);
40
        } else {
41
            $header = '';
42
43
            if (null !== ($s = $o->getModifiers())) {
44
                $header .= '<var>'.$s.'</var> ';
45
            }
46
47
            if (null !== ($s = $o->getName())) {
48
                $header .= '<dfn>'.$this->renderer->escape($s).'('.$this->renderer->escape($o->getParams()).')</dfn> ';
49
            }
50
51
            $header .= '<var>Closure</var> ';
52
            $header .= $this->renderer->escape(Kint::shortenPath($o->filename)).':'.(int) $o->startline;
53
        }
54
55
        $header = $this->renderer->renderHeaderWrapper($o, (bool) \strlen($children), $header);
56
57
        return '<dl>'.$header.$children.'</dl>';
58
    }
59
}
60