Test Setup Failed
Push — test ( b06172...b6afec )
by Jonathan
03:22
created

RichRenderer::renderTab()   C

Complexity

Conditions 17
Paths 41

Size

Total Lines 50
Code Lines 29

Duplication

Lines 9
Ratio 18 %

Importance

Changes 0
Metric Value
cc 17
eloc 29
nc 41
nop 2
dl 9
loc 50
rs 5.3442
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
            } else {
322
                if (preg_match('/(:?[\r\n\t\f\v]| {2})/', $rep->contents)) {
323
                    $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...
324
                } elseif (self::$strlen_max && BlobObject::strlen($o->getValueShort()) > self::$strlen_max) {
325
                    $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...
326
                }
327
328
                if (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...
329
                    $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...
330
                }
331
            }
332
333
            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...
334
                return '<pre>'.$this->escape($rep->contents)."\n</pre>";
335
            }
336
        } elseif ($rep->contents instanceof BasicObject) {
337
            return $this->render($rep->contents);
338
        }
339
340
        return;
341
    }
342
343
    protected static function renderJs()
344
    {
345
        return file_get_contents(KINT_DIR.'/resources/compiled/rich.js');
346
    }
347
348 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...
349
    {
350
        if (file_exists(KINT_DIR.'/resources/compiled/'.self::$theme)) {
351
            return file_get_contents(KINT_DIR.'/resources/compiled/'.self::$theme);
352
        } else {
353
            return file_get_contents(self::$theme);
354
        }
355
    }
356
357
    protected static function renderFolder()
358
    {
359
        if (self::$folder) {
360
            return '<div class="kint-rich kint-folder"><dl><dt class="kint-parent"><nav></nav>Kint</dt><dd class="kint-folder"></dd></dl></div>';
361
        } else {
362
            return '';
363
        }
364
    }
365
366 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...
367
    {
368
        $output = '';
369
370
        if (!self::$been_run || $this->mod_return) {
371
            foreach (self::$pre_render_sources as $type => $values) {
372
                $contents = '';
373
                foreach ($values as $v) {
374
                    $contents .= call_user_func($v, $this);
375
                }
376
377
                if (!strlen($contents)) {
378
                    continue;
379
                }
380
381
                switch ($type) {
382
                    case 'script':
383
                        $output .= '<script class="kint-script">'.$contents.'</script>';
384
                        break;
385
                    case 'style':
386
                        $output .= '<style class="kint-style">'.$contents.'</style>';
387
                        break;
388
                    default:
389
                        $output .= $contents;
390
                }
391
            }
392
393
            if (!$this->mod_return) {
394
                self::$been_run = true;
395
            }
396
        }
397
398
        return $output.'<div class="kint-rich">';
399
    }
400
401
    public function postRender()
402
    {
403
        if (!$this->show_minitrace) {
404
            return '</div>';
405
        }
406
407
        $output = '<footer>';
408
        $output .= '<span class="kint-popup-trigger" title="Open in new window">&boxbox;</span> ';
409
410
        if (isset($this->callee['file'])) {
411
            if (!empty($this->mini_trace)) {
412
                $output .= '<nav></nav>';
413
            }
414
415
            $output .= 'Called from '.$this->ideLink($this->callee['file'], $this->callee['line']);
416
        }
417
418
        $caller = '';
419
420
        if (isset($this->previous_caller['class'])) {
421
            $caller .= $this->previous_caller['class'];
422
        }
423
        if (isset($this->previous_caller['type'])) {
424
            $caller .= $this->previous_caller['type'];
425
        }
426 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...
427
            && !in_array(
428
                $this->previous_caller['function'],
429
                array('include', 'include_once', 'require', 'require_once')
430
            )
431
        ) {
432
            $caller .= $this->previous_caller['function'].'()';
433
        }
434
435
        if ($caller) {
436
            $output .= ' ['.$caller.']';
437
        }
438
439
        if (!empty($this->mini_trace)) {
440
            $output .= '<ol>';
441
            foreach ($this->mini_trace as $step) {
442
                $output .= '<li>'.$this->ideLink($step['file'], $step['line']); // closing tag not required
443
                if (isset($step['function'])
444
                    && !in_array($step['function'], array('include', 'include_once', 'require', 'require_once'))
445
                ) {
446
                    $output .= ' [';
447
                    if (isset($step['class'])) {
448
                        $output .= $step['class'];
449
                    }
450
                    if (isset($step['type'])) {
451
                        $output .= $step['type'];
452
                    }
453
                    $output .= $step['function'].'()]';
454
                }
455
            }
456
            $output .= '</ol>';
457
        }
458
459
        $output .= '</footer></div>';
460
461
        return $output;
462
    }
463
464 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...
465
    {
466
        if ($encoding === false) {
467
            $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...
468
        }
469
470
        $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...
471
472
        if ($encoding === false || $encoding === 'ASCII') {
473
            $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...
474
        }
475
476
        $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...
477
478
        // this call converts all non-ASCII characters into numeirc htmlentities
479
        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...
480
            $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...
481
        }
482
483
        return $string;
484
    }
485
486 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...
487
    {
488
        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...
489
            $plugin = end($plugins);
490
491
            if (!isset($this->plugin_objs[$plugin])) {
492
                $this->plugin_objs[$plugin] = new $plugin($this);
493
            }
494
495
            return $this->plugin_objs[$plugin];
496
        }
497
    }
498
499 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...
500
    {
501
        $shortenedPath = $this->escape(Kint::shortenPath($file));
502
        if (!$this->file_link_format) {
503
            return $shortenedPath.':'.$line;
504
        }
505
506
        $ideLink = Kint::getIdeLink($file, $line);
507
        $class = (strpos($ideLink, 'http://') === 0) ? 'class="kint-ide-link" ' : '';
508
509
        return "<a {$class}href=\"{$ideLink}\">{$shortenedPath}:{$line}</a>";
510
    }
511
}
512