Kint_Renderer_Rich_Docstring::render()   D
last analyzed

Complexity

Conditions 9
Paths 33

Size

Total Lines 34
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 19
nc 33
nop 1
dl 0
loc 34
rs 4.909
c 0
b 0
f 0
1
<?php
2
3
class Kint_Renderer_Rich_Docstring extends Kint_Renderer_Rich_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Renderer_Rich_Docstring 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($r)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. 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
        if (!($r instanceof Kint_Object_Representation_Docstring)) {
8
            return false;
9
        }
10
11
        $docstring = array();
12
        foreach (explode("\n", $r->contents) as $line) {
13
            $docstring[] = trim($line);
14
        }
15
16
        $docstring = implode("\n", $docstring);
17
18
        $location = array();
19
20
        if ($r->class) {
21
            $location[] = 'Inherited from '.$this->renderer->escape($r->class);
22
        }
23
        if ($r->file && $r->line) {
24
            $location[] = 'Defined in '.$this->renderer->escape(Kint::shortenPath($r->file)).':'.((int) $r->line);
25
        }
26
27
        if ($location) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $location of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
28
            if (strlen($docstring)) {
29
                $docstring .= "\n\n";
30
            }
31
32
            $location = '<small>'.implode("\n", $location).'</small>';
33
        } elseif (strlen($docstring) === 0) {
34
            return '';
35
        }
36
37
        return '<pre>'.$this->renderer->escape($docstring).$location.'</pre>';
38
    }
39
}
40