Kint_Renderer_Rich_Callable::render()   C
last analyzed

Complexity

Conditions 17
Paths 145

Size

Total Lines 56
Code Lines 30

Duplication

Lines 9
Ratio 16.07 %

Importance

Changes 0
Metric Value
cc 17
eloc 30
nc 145
nop 1
dl 9
loc 56
rs 5.9525
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
class Kint_Renderer_Rich_Callable extends Kint_Renderer_Rich_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Renderer_Rich_Callable does not seem to conform to the naming convention (^[A-Z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
The property $method_cache is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
4
{
5
    protected static $method_cache = array();
0 ignored issues
show
Coding Style introduced by
$method_cache does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
6
7
    public function render($o)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
8
    {
9
        if ($o instanceof Kint_Object_Method && strlen($o->owner_class) && strlen($o->name) && !empty(self::$method_cache[$o->owner_class][$o->name])) {
10
            $children = self::$method_cache[$o->owner_class][$o->name]['children'];
11
12
            $header = $this->renderer->renderHeaderWrapper($o, (bool) strlen($children), self::$method_cache[$o->owner_class][$o->name]['header']);
13
14
            return '<dl>'.$header.$children.'</dl>';
15
        }
16
17
        $children = $this->renderer->renderChildren($o);
18
19
        $header = '';
20
21
        if (($s = $o->getModifiers()) !== null) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $s. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
22
            $header .= '<var>'.$s.'</var> ';
23
        }
24
25
        if (($s = $o->getName()) !== null) {
26
            $function = $this->renderer->escape($s).'('.$this->renderer->escape($o->getParams()).')';
27
28 View Code Duplication
            if (($url = $o->getPhpDocUrl()) !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
                $function = '<a href="'.$url.'" target=_blank>'.$function.'</a>';
30
            }
31
32
            $header .= '<dfn>'.$function.'</dfn>';
33
        }
34
35
        if (!empty($o->returntype)) {
36
            $header .= ': <var>'.$this->renderer->escape($o->returntype).'</var>';
37
        }
38
39 View Code Duplication
        if (($s = $o->getValueShort()) !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
            if (Kint_Renderer_Rich::$strlen_max && Kint_Object_Blob::strlen($s) > Kint_Renderer_Rich::$strlen_max) {
41
                $s = substr($s, 0, Kint_Renderer_Rich::$strlen_max).'...';
42
            }
43
            $header .= ' '.$this->renderer->escape($s);
44
        }
45
46
        if ($o instanceof Kint_Object_Method && strlen($o->owner_class) && strlen($o->name)) {
47
            $cache = array(
48
                'header' => $header,
49
                'children' => $children,
50
            );
51
52
            if (!isset(self::$method_cache[$o->owner_class])) {
53
                self::$method_cache[$o->owner_class] = array($o->name => $cache);
54
            } elseif (!isset(self::$method_cache[$o->owner_class][$o->name])) {
55
                self::$method_cache[$o->owner_class][$o->name] = $cache;
56
            }
57
        }
58
59
        $header = $this->renderer->renderHeaderWrapper($o, (bool) strlen($children), $header);
60
61
        return '<dl>'.$header.$children.'</dl>';
62
    }
63
}
64