Kint_Renderer_Text_Trace   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 81
Duplicated Lines 17.28 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 14
loc 81
rs 10
c 0
b 0
f 0
wmc 17
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
D render() 14 78 17

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
class Kint_Renderer_Text_Trace extends Kint_Renderer_Text_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Renderer_Text_Trace 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
        $out = '';
8
9
        if ($o->depth == 0) {
10
            $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL;
11
        }
12
13
        $out .= $this->renderer->renderHeader($o).':'.PHP_EOL;
14
15
        $indent = str_repeat(' ', ($o->depth + 1) * $this->renderer->indent_width);
16
17
        $i = 1;
18
        foreach ($o->value->contents as $frame) {
19
            $framedesc = $indent.str_pad($i.': ', 4, ' ');
20
21
            if ($frame->trace['file']) {
22
                $framedesc .= $this->renderer->ideLink($frame->trace['file'], $frame->trace['line']).PHP_EOL;
23
            } else {
24
                $framedesc .= 'PHP internal call'.PHP_EOL;
25
            }
26
27
            $framedesc .= $indent.'    ';
28
29
            if ($frame->trace['class']) {
30
                $framedesc .= $this->renderer->escape($frame->trace['class']);
31
32
                if ($frame->trace['object']) {
33
                    $framedesc .= $this->renderer->escape('->');
34
                } else {
35
                    $framedesc .= '::';
36
                }
37
            }
38
39
            if (is_string($frame->trace['function'])) {
40
                $framedesc .= $this->renderer->escape($frame->trace['function']).'(...)';
41
            } elseif ($frame->trace['function'] instanceof Kint_Object_Method) {
42
                $framedesc .= $this->renderer->escape($frame->trace['function']->getName());
43
                $framedesc .= '('.$this->renderer->escape($frame->trace['function']->getParams()).')';
44
            }
45
46
            $out .= $this->renderer->colorType($framedesc).PHP_EOL.PHP_EOL;
47
48
            if ($source = $frame->getRepresentation('source')) {
49
                $line_wanted = $source->line;
0 ignored issues
show
Coding Style introduced by
$line_wanted 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...
50
                $source = $source->source;
51
52
                // Trim empty lines from the start and end of the source
53 View Code Duplication
                foreach ($source as $linenum => $line) {
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...
54
                    if (trim($line) || $linenum === $line_wanted) {
0 ignored issues
show
Coding Style introduced by
$line_wanted 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...
55
                        break;
56
                    } else {
57
                        unset($source[$linenum]);
58
                    }
59
                }
60
61 View Code Duplication
                foreach (array_reverse($source, true) as $linenum => $line) {
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...
62
                    if (trim($line) || $linenum === $line_wanted) {
0 ignored issues
show
Coding Style introduced by
$line_wanted 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...
63
                        break;
64
                    } else {
65
                        unset($source[$linenum]);
66
                    }
67
                }
68
69
                foreach ($source as $lineno => $line) {
70
                    if ($lineno == $line_wanted) {
0 ignored issues
show
Coding Style introduced by
$line_wanted 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...
71
                        $out .= $indent.$this->renderer->colorValue($this->renderer->escape($line)).PHP_EOL;
72
                    } else {
73
                        $out .= $indent.$this->renderer->escape($line).PHP_EOL;
74
                    }
75
                }
76
            }
77
78
            ++$i;
79
        }
80
81
        return $out;
82
    }
83
}
84