Test Setup Failed
Push — next ( 5d2fc6...738e04 )
by Jonathan
03:23
created

BlacklistPlugin::blacklist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 2
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Kint\Parser;
4
5
use Kint\Object\BasicObject;
6
use Kint\Object\InstanceObject;
7
8
class BlacklistPlugin extends Plugin
0 ignored issues
show
Coding Style introduced by
The property $shallow_blacklist 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...
9
{
10
    /**
11
     * List of classes and interfaces to blacklist.
12
     *
13
     * @var array
14
     */
15
    public static $blacklist = array();
16
17
    /**
18
     * List of classes and interfaces to blacklist except when dumped directly.
19
     *
20
     * @var array
21
     */
22
    public static $shallow_blacklist = array();
0 ignored issues
show
Coding Style introduced by
$shallow_blacklist 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...
23
24
    public function getTypes()
25
    {
26
        return array('object');
27
    }
28
29
    public function getTriggers()
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...
30
    {
31
        return Parser::TRIGGER_BEGIN;
32
    }
33
34
    public function parse(&$var, BasicObject &$o, $trigger)
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...
35
    {
36
        foreach (self::$blacklist as $class) {
37
            if ($var instanceof $class) {
38
                return $this->blacklist($var, $o);
39
            }
40
        }
41
42
        if ($o->depth <= 0) {
43
            return;
44
        }
45
46
        foreach (self::$shallow_blacklist as $class) {
47
            if ($var instanceof $class) {
48
                return $this->blacklist($var, $o);
49
            }
50
        }
51
    }
52
53
    protected function blacklist(&$var, &$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...
54
    {
55
        $object = $o->transplant(new InstanceObject());
56
        $object->classname = get_class($var);
57
        $object->hash = spl_object_hash($var);
58
        $object->clearRepresentations();
59
        $object->value = null;
60
        $object->size = null;
61
        $object->hints[] = 'blacklist';
62
63
        $o = $object;
64
65
        $this->parser->haltParse();
66
67
        return;
68
    }
69
}
70