Test Setup Failed
Push — next ( 738e04...b06172 )
by Jonathan
25:05
created

RichRenderer::renderTab()   D

Complexity

Conditions 19
Paths 45

Size

Total Lines 48
Code Lines 28

Duplication

Lines 9
Ratio 18.75 %

Importance

Changes 0
Metric Value
cc 19
eloc 28
nc 45
nop 2
dl 9
loc 48
rs 4.8943
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
namespace Kint\Renderer;
4
5
use Kint\Kint;
6
use Kint\Object\BasicObject;
7
use Kint\Object\BlobObject;
8
use Kint\Object\InstanceObject;
9
use Kint\Object\Representation\Representation;
10
11
class RichRenderer extends Renderer
0 ignored issues
show
Coding Style introduced by
The property $object_plugins 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...
Coding Style introduced by
The property $tab_plugins 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...
Coding Style introduced by
The property $pre_render_sources 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...
Coding Style introduced by
The property $access_paths 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...
Coding Style introduced by
The property $strlen_max 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...
Coding Style introduced by
The property $escape_types 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...
Coding Style introduced by
The property $been_run 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...
Coding Style introduced by
The property $plugin_objs 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...
Coding Style introduced by
The property $mod_return 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...
Coding Style introduced by
The property $mini_trace 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...
Coding Style introduced by
The property $previous_caller 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...
Coding Style introduced by
The property $file_link_format 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...
Coding Style introduced by
The property $show_minitrace 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...
Coding Style introduced by
The property $auto_expand 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...
12
{
13
    /**
14
     * RichRenderer object plugins should implement Kint\Renderer\Rich\ObjectPluginInterface.
15
     */
16
    public static $object_plugins = array(
0 ignored issues
show
Coding Style introduced by
$object_plugins 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...
17
        'blacklist' => 'Kint\\Renderer\\Rich\\BlacklistPlugin',
18
        'callable' => 'Kint\\Renderer\\Rich\\CallablePlugin',
19
        'closure' => 'Kint\\Renderer\\Rich\\ClosurePlugin',
20
        'color' => 'Kint\\Renderer\\Rich\\ColorPlugin',
21
        'depth_limit' => 'Kint\\Renderer\\Rich\\DepthLimitPlugin',
22
        'nothing' => 'Kint\\Renderer\\Rich\\NothingPlugin',
23
        'recursion' => 'Kint\\Renderer\\Rich\\RecursionPlugin',
24
        'simplexml_element' => 'Kint\\Renderer\\Rich\\SimpleXMLElementPlugin',
25
        'trace_frame' => 'Kint\\Renderer\\Rich\\TraceFramePlugin',
26
    );
27
28
    /**
29
     * RichRenderer tab plugins should implement Kint\Renderer\Rich\TabPluginInterface.
30
     */
31
    public static $tab_plugins = array(
0 ignored issues
show
Coding Style introduced by
$tab_plugins 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...
32
        'binary' => 'Kint\\Renderer\\Rich\\BinaryPlugin',
33
        'color' => 'Kint\\Renderer\\Rich\\ColorPlugin',
34
        'docstring' => 'Kint\\Renderer\\Rich\\DocstringPlugin',
35
        'microtime' => 'Kint\\Renderer\\Rich\\MicrotimePlugin',
36
        'source' => 'Kint\\Renderer\\Rich\\SourcePlugin',
37
        'table' => 'Kint\\Renderer\\Rich\\TablePlugin',
38
        'timestamp' => 'Kint\\Renderer\\Rich\\TimestampPlugin',
39
    );
40
41
    public static $pre_render_sources = array(
0 ignored issues
show
Coding Style introduced by
$pre_render_sources 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...
42
        'script' => array(
43
            array('Kint\\Renderer\\RichRenderer', 'renderJs'),
44
            array('Kint\\Renderer\\Rich\\MicrotimePlugin', 'renderJs'),
45
        ),
46
        'style' => array(
47
            array('Kint\\Renderer\\RichRenderer', 'renderCss'),
48
        ),
49
        'raw' => array(
50
            array('Kint\\Renderer\\RichRenderer', 'renderFolder'),
51
        ),
52
    );
53
54
    /**
55
     * Whether or not to render access paths.
56
     *
57
     * Access paths can become incredibly heavy with very deep and wide
58
     * structures. Given mostly public variables it will typically make
59
     * up one quarter of the output HTML size.
60
     *
61
     * If this is an unacceptably large amount and your browser is groaning
62
     * under the weight of the access paths - your first order of buisiness
63
     * should be to get a new browser. Failing that, use this to turn them off.
64
     *
65
     * @var bool
66
     */
67
    public static $access_paths = true;
0 ignored issues
show
Coding Style introduced by
$access_paths 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...
68
69
    /**
70
     * The maximum length of a string before it is truncated.
71
     *
72
     * Falsey to disable
73
     *
74
     * @var int
75
     */
76
    public static $strlen_max = 80;
0 ignored issues
show
Coding Style introduced by
$strlen_max 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...
77
78
    /**
79
     * Path to the CSS file to load by default.
80
     *
81
     * @var string
82
     */
83
    public static $theme = 'original.css';
84
85
    /**
86
     * Assume types and sizes don't need to be escaped.
87
     *
88
     * Turn this off if you use anything but ascii in your class names,
89
     * but it'll cause a slowdown of around 10%
90
     *
91
     * @var bool
92
     */
93
    public static $escape_types = false;
0 ignored issues
show
Coding Style introduced by
$escape_types 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...
94
95
    /**
96
     * Move all dumps to a folder at the bottom of the body.
97
     *
98
     * @var bool
99
     */
100
    public static $folder = true;
101
102
    /**
103
     * Sort mode for object properties.
104
     *
105
     * @var int
106
     */
107
    public static $sort = self::SORT_NONE;
108
109
    protected static $been_run = false;
0 ignored issues
show
Coding Style introduced by
$been_run 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...
110
111
    protected $plugin_objs = array();
0 ignored issues
show
Coding Style introduced by
$plugin_objs 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...
112
    protected $mod_return = false;
0 ignored issues
show
Coding Style introduced by
$mod_return 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...
113
    protected $callee;
114
    protected $mini_trace;
0 ignored issues
show
Coding Style introduced by
$mini_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...
115
    protected $previous_caller;
0 ignored issues
show
Coding Style introduced by
$previous_caller 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...
116
    protected $file_link_format = false;
0 ignored issues
show
Coding Style introduced by
$file_link_format 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...
117
    protected $show_minitrace = true;
0 ignored issues
show
Coding Style introduced by
$show_minitrace 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...
118
    protected $auto_expand = false;
0 ignored issues
show
Coding Style introduced by
$auto_expand 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...
119
120
    public function __construct(array $params = array())
121
    {
122
        parent::__construct($params);
123
124
        $params += array(
125
            'modifiers' => array(),
126
            'minitrace' => array(),
127
            'callee' => null,
128
            'caller' => null,
129
        );
130
131
        $this->callee = $params['callee'];
132
        $this->mini_trace = $params['minitrace'];
133
        $this->previous_caller = $params['caller'];
134
135
        if (isset($params['settings']['return'])) {
136
            $this->mod_return = $params['settings']['return'];
137
        }
138
139
        if (isset($params['settings']['file_link_format'])) {
140
            $this->file_link_format = $params['settings']['file_link_format'];
141
        }
142
143
        if (empty($params['settings']['display_called_from'])) {
144
            $this->show_minitrace = false;
145
        }
146
147
        if (!empty($params['settings']['expanded'])) {
148
            $this->auto_expand = true;
149
        }
150
    }
151
152
    public function render(BasicObject $o)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
153
    {
154
        if ($plugin = $this->getPlugin(self::$object_plugins, $o->hints)) {
155
            if (strlen($output = $plugin->renderObject($o))) {
156
                return $output;
157
            }
158
        }
159
160
        $children = $this->renderChildren($o);
161
        $header = $this->renderHeaderWrapper($o, (bool) strlen($children), $this->renderHeader($o));
162
163
        return '<dl>'.$header.$children.'</dl>';
164
    }
165
166
    public function renderHeaderWrapper(BasicObject $o, $has_children, $contents)
0 ignored issues
show
Coding Style introduced by
$has_children 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...
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...
Coding Style Naming introduced by
The parameter $has_children is not named in camelCase.

This check marks parameter 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...
167
    {
168
        $out = '<dt';
169
170
        if ($has_children) {
0 ignored issues
show
Coding Style introduced by
$has_children 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...
171
            $out .= ' class="kint-parent';
172
173
            if ($this->auto_expand) {
174
                $out .= ' kint-show';
175
            }
176
177
            $out .= '"';
178
        }
179
180
        $out .= '>';
181
182 View Code Duplication
        if (self::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath()) {
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...
Comprehensibility introduced by
Avoid variables with short names like $ap. 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...
183
            $out .= '<span class="kint-access-path-trigger" title="Show access path">&rlarr;</span>';
184
        }
185
186
        if ($has_children) {
0 ignored issues
show
Coding Style introduced by
$has_children 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...
187
            $out .= '<span class="kint-popup-trigger" title="Open in new window">&boxbox;</span><nav></nav>';
188
        }
189
190
        $out .= $contents;
191
192
        if (!empty($ap)) {
193
            $out .= '<div class="access-path">'.$this->escape($ap).'</div>';
194
        }
195
196
        return $out.'</dt>';
197
    }
198
199
    public function renderHeader(BasicObject $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...
200
    {
201
        $output = '';
202
203
        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...
204
            $output .= '<var>'.$s.'</var> ';
205
        }
206
207
        if (($s = $o->getName()) !== null) {
208
            $output .= '<dfn>'.$this->escape($s).'</dfn> ';
209
210
            if ($s = $o->getOperator()) {
211
                $output .= $this->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...
212
            }
213
        }
214
215 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...
216
            if (self::$escape_types) {
217
                $s = $this->escape($s);
218
            }
219
220
            if ($o->reference) {
221
                $s = '&amp;'.$s;
222
            }
223
224
            $output .= '<var>'.$s.'</var> ';
225
        }
226
227 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...
228
            if (self::$escape_types) {
229
                $s = $this->escape($s);
230
            }
231
            $output .= '('.$s.') ';
232
        }
233
234
        if (($s = $o->getValueShort()) !== null) {
235
            $s = preg_replace('/\s+/', ' ', $s);
236
237
            if (self::$strlen_max && BlobObject::strlen($s) > self::$strlen_max) {
238
                $s = substr($s, 0, self::$strlen_max).'...';
239
            }
240
            $output .= $this->escape($s);
241
        }
242
243
        return trim($output);
244
    }
245
246
    public function renderChildren(BasicObject $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...
247
    {
248
        $contents = array();
249
        $tabs = array();
250
251
        foreach ($o->getRepresentations() as $rep) {
252
            $result = $this->renderTab($o, $rep);
253
            if (strlen($result)) {
254
                $contents[] = $result;
255
                $tabs[] = $rep;
256
            }
257
        }
258
259
        if (empty($tabs)) {
260
            return '';
261
        }
262
263
        $output = '<dd>';
264
265
        if (count($tabs) === 1 && $tabs[0]->labelIsImplicit()) {
266
            $output .= reset($contents);
267
        } else {
268
            $output .= '<ul class="kint-tabs">';
269
270
            foreach ($tabs as $i => $tab) {
271
                if ($i === 0) {
272
                    $output .= '<li class="kint-active-tab">';
273
                } else {
274
                    $output .= '<li>';
275
                }
276
277
                $output .= $this->escape($tab->getLabel()).'</li>';
278
            }
279
280
            $output .= '</ul><ul>';
281
282
            foreach ($contents as $tab) {
283
                $output .= '<li>'.$tab.'</li>';
284
            }
285
286
            $output .= '</ul>';
287
        }
288
289
        return $output.'</dd>';
290
    }
291
292
    protected function renderTab(BasicObject $o, Representation $rep)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
293
    {
294
        if ($plugin = $this->getPlugin(self::$tab_plugins, $rep->hints)) {
295
            if (strlen($output = $plugin->renderTab($rep))) {
296
                return $output;
297
            }
298
        }
299
300
        if (is_array($rep->contents)) {
301
            $output = '';
302
303 View Code Duplication
            if ($o instanceof InstanceObject && $rep->getName() === 'properties') {
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...
304
                foreach (self::sortProperties($rep->contents, self::$sort) as $obj) {
305
                    $output .= $this->render($obj);
306
                }
307
            } else {
308
                foreach ($rep->contents as $obj) {
309
                    $output .= $this->render($obj);
310
                }
311
            }
312
313
            return $output;
314
        } elseif (is_string($rep->contents)) {
315
            $show_contents = false;
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
316
317
            // If it is the value representation of a string and its whitespace
318
            // was truncated in the header, always display the full string
319
            if ($o->type !== 'string' || $o->value !== $rep) {
320
                $show_contents = true;
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
321
            } elseif (preg_match('/(:?[\r\n\t\f\v]| {2})/', $rep->contents)) {
322
                $show_contents = true;
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
323
            } elseif (self::$strlen_max && BlobObject::strlen($rep->contents) > self::$strlen_max) {
324
                $show_contents = true;
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
325
            }
326
327
            if ($o->type === 'string' && $o->value === $rep && empty($o->encoding)) {
0 ignored issues
show
Bug introduced by
The property encoding does not seem to exist in Kint\Object\BasicObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
328
                $show_contents = false;
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
329
            }
330
331
            if ($show_contents) {
0 ignored issues
show
Coding Style introduced by
$show_contents 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...
332
                return '<pre>'.$this->escape($rep->contents)."\n</pre>";
333
            }
334
        } elseif ($rep->contents instanceof BasicObject) {
335
            return $this->render($rep->contents);
336
        }
337
338
        return;
339
    }
340
341
    protected static function renderJs()
342
    {
343
        return file_get_contents(KINT_DIR.'/resources/compiled/rich.js');
344
    }
345
346 View Code Duplication
    protected static function renderCss()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
347
    {
348
        if (file_exists(KINT_DIR.'/resources/compiled/'.self::$theme)) {
349
            return file_get_contents(KINT_DIR.'/resources/compiled/'.self::$theme);
350
        } else {
351
            return file_get_contents(self::$theme);
352
        }
353
    }
354
355
    protected static function renderFolder()
356
    {
357
        if (self::$folder) {
358
            return '<div class="kint-rich kint-folder"><dl><dt class="kint-parent"><nav></nav>Kint</dt><dd class="kint-folder"></dd></dl></div>';
359
        } else {
360
            return '';
361
        }
362
    }
363
364 View Code Duplication
    public function preRender()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
365
    {
366
        $output = '';
367
368
        if (!self::$been_run || $this->mod_return) {
369
            foreach (self::$pre_render_sources as $type => $values) {
370
                $contents = '';
371
                foreach ($values as $v) {
372
                    $contents .= call_user_func($v, $this);
373
                }
374
375
                if (!strlen($contents)) {
376
                    continue;
377
                }
378
379
                switch ($type) {
380
                    case 'script':
381
                        $output .= '<script class="kint-script">'.$contents.'</script>';
382
                        break;
383
                    case 'style':
384
                        $output .= '<style class="kint-style">'.$contents.'</style>';
385
                        break;
386
                    default:
387
                        $output .= $contents;
388
                }
389
            }
390
391
            if (!$this->mod_return) {
392
                self::$been_run = true;
393
            }
394
        }
395
396
        return $output.'<div class="kint-rich">';
397
    }
398
399
    public function postRender()
400
    {
401
        if (!$this->show_minitrace) {
402
            return '</div>';
403
        }
404
405
        $output = '<footer>';
406
        $output .= '<span class="kint-popup-trigger" title="Open in new window">&boxbox;</span> ';
407
408
        if (isset($this->callee['file'])) {
409
            if (!empty($this->mini_trace)) {
410
                $output .= '<nav></nav>';
411
            }
412
413
            $output .= 'Called from '.$this->ideLink($this->callee['file'], $this->callee['line']);
414
        }
415
416
        $caller = '';
417
418
        if (isset($this->previous_caller['class'])) {
419
            $caller .= $this->previous_caller['class'];
420
        }
421
        if (isset($this->previous_caller['type'])) {
422
            $caller .= $this->previous_caller['type'];
423
        }
424 View Code Duplication
        if (isset($this->previous_caller['function'])
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...
425
            && !in_array(
426
                $this->previous_caller['function'],
427
                array('include', 'include_once', 'require', 'require_once')
428
            )
429
        ) {
430
            $caller .= $this->previous_caller['function'].'()';
431
        }
432
433
        if ($caller) {
434
            $output .= ' ['.$caller.']';
435
        }
436
437
        if (!empty($this->mini_trace)) {
438
            $output .= '<ol>';
439
            foreach ($this->mini_trace as $step) {
440
                $output .= '<li>'.$this->ideLink($step['file'], $step['line']); // closing tag not required
441
                if (isset($step['function'])
442
                    && !in_array($step['function'], array('include', 'include_once', 'require', 'require_once'))
443
                ) {
444
                    $output .= ' [';
445
                    if (isset($step['class'])) {
446
                        $output .= $step['class'];
447
                    }
448
                    if (isset($step['type'])) {
449
                        $output .= $step['type'];
450
                    }
451
                    $output .= $step['function'].'()]';
452
                }
453
            }
454
            $output .= '</ol>';
455
        }
456
457
        $output .= '</footer></div>';
458
459
        return $output;
460
    }
461
462 View Code Duplication
    public function escape($string, $encoding = false)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
463
    {
464
        if ($encoding === false) {
465
            $encoding = BlobObject::detectEncoding($string);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $encoding. This often makes code more readable.
Loading history...
466
        }
467
468
        $original_encoding = $encoding;
0 ignored issues
show
Coding Style introduced by
$original_encoding 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...
469
470
        if ($encoding === false || $encoding === 'ASCII') {
471
            $encoding = 'UTF-8';
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $encoding. This often makes code more readable.
Loading history...
472
        }
473
474
        $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
475
476
        // this call converts all non-ASCII characters into numeirc htmlentities
477
        if (extension_loaded('mbstring') && $original_encoding !== 'ASCII') {
0 ignored issues
show
Coding Style introduced by
$original_encoding 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...
478
            $string = mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
479
        }
480
481
        return $string;
482
    }
483
484 View Code Duplication
    protected function getPlugin(array $plugins, array $hints)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Duplication introduced by
This method seems to be duplicated in 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...
485
    {
486
        if ($plugins = $this->matchPlugins($plugins, $hints)) {
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $plugins. This often makes code more readable.
Loading history...
487
            $plugin = end($plugins);
488
489
            if (!isset($this->plugin_objs[$plugin])) {
490
                $this->plugin_objs[$plugin] = new $plugin($this);
491
            }
492
493
            return $this->plugin_objs[$plugin];
494
        }
495
    }
496
497 View Code Duplication
    protected function ideLink($file, $line)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Duplication introduced by
This method seems to be duplicated in 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...
498
    {
499
        $shortenedPath = $this->escape(Kint::shortenPath($file));
500
        if (!$this->file_link_format) {
501
            return $shortenedPath.':'.$line;
502
        }
503
504
        $ideLink = Kint::getIdeLink($file, $line);
505
        $class = (strpos($ideLink, 'http://') === 0) ? 'class="kint-ide-link" ' : '';
506
507
        return "<a {$class}href=\"{$ideLink}\">{$shortenedPath}:{$line}</a>";
508
    }
509
}
510