Kint_Renderer_Rich_SimpleXMLElement::render()   D
last analyzed

Complexity

Conditions 13
Paths 144

Size

Total Lines 47
Code Lines 24

Duplication

Lines 25
Ratio 53.19 %

Importance

Changes 0
Metric Value
cc 13
eloc 24
nc 144
nop 1
dl 25
loc 47
rs 4.7893
c 0
b 0
f 0

How to fix   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_SimpleXMLElement extends Kint_Renderer_Rich_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Renderer_Rich_SimpleXMLElement 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...
4
{
5
    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...
6
    {
7
        $children = $this->renderer->renderChildren($o);
8
9
        $header = '';
10
11
        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...
12
            $header .= '<var>'.$s.'</var> ';
13
        }
14
15 View Code Duplication
        if (($s = $o->getName()) !== 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...
16
            $header .= '<dfn>'.$this->renderer->escape($s).'</dfn> ';
17
18
            if ($s = $o->getOperator()) {
19
                $header .= $this->renderer->escape($s, 'ASCII').' ';
0 ignored issues
show
Documentation introduced by
'ASCII' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
20
            }
21
        }
22
23 View Code Duplication
        if (($s = $o->getType()) !== 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...
24
            $s = $this->renderer->escape($s);
25
26
            if ($o->reference) {
27
                $s = '&amp;'.$s;
28
            }
29
30
            $header .= '<var>'.$this->renderer->escape($s).'</var> ';
31
        }
32
33 View Code Duplication
        if (($s = $o->getSize()) !== 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...
34
            $header .= '('.$this->renderer->escape($s).') ';
35
        }
36
37
        if ($s === null && $c = $o->getRepresentation('contents')) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. 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...
38
            $c = reset($c->contents);
39
40 View Code Duplication
            if ($c && ($s = $c->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...
41
                if (Kint_Renderer_Rich::$strlen_max && Kint_Object_Blob::strlen($s) > Kint_Renderer_Rich::$strlen_max) {
42
                    $s = substr($s, 0, Kint_Renderer_Rich::$strlen_max).'...';
43
                }
44
                $header .= $this->renderer->escape($s);
45
            }
46
        }
47
48
        $header = $this->renderer->renderHeaderWrapper($o, (bool) strlen($children), $header);
49
50
        return '<dl>'.$header.$children.'</dl>';
51
    }
52
}
53