Kint_Object_Parameter   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A getName() 0 4 1
C __construct() 0 46 14
A getDefault() 0 4 1
1
<?php
2
3
class Kint_Object_Parameter extends Kint_Object
0 ignored issues
show
Coding Style introduced by
Kint_Object_Parameter 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...
Coding Style introduced by
The property $type_hint 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...
4
{
5
    public $type_hint = null;
0 ignored issues
show
Coding Style introduced by
$type_hint 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...
6
    public $default = null;
7
    public $position = null;
8
    public $hints = array('parameter');
9
10
    public function getType()
11
    {
12
        return $this->type_hint;
13
    }
14
15
    public function getName()
16
    {
17
        return '$'.$this->name;
18
    }
19
20
    public function __construct(ReflectionParameter $param)
21
    {
22
        if (method_exists('ReflectionParameter', 'getType')) {
23
            if ($type = $param->getType()) {
24
                $this->type_hint = (string) $type;
25
            }
26
        } else {
27
            if ($param->isArray()) {
28
                $this->type_hint = 'array';
29
            } else {
30
                try {
31
                    if ($this->type_hint = $param->getClass()) {
32
                        $this->type_hint = $this->type_hint->name;
33
                    }
34
                } catch (ReflectionException $e) {
35
                    preg_match('/\[\s\<\w+?>\s([\w]+)/s', $param->__toString(), $matches);
36
                    $this->type_hint = isset($matches[1]) ? $matches[1] : '';
37
                }
38
            }
39
        }
40
41
        $this->reference = $param->isPassedByReference();
42
        $this->name = $param->getName();
43
44
        if (KINT_PHP523) {
45
            $this->position = $param->getPosition();
46
        }
47
48
        if ($param->isDefaultValueAvailable()) {
49
            $default = $param->getDefaultValue();
50
            switch (gettype($default)) {
51
                case 'NULL':
52
                    $this->default = 'null';
53
                    break;
54
                case 'boolean':
55
                    $this->default = $default ? 'true' : 'false';
56
                    break;
57
                case 'array':
58
                    $this->default = count($default) ? 'array(...)' : 'array()';
59
                    break;
60
                default:
61
                    $this->default = var_export($default, true);
62
                    break;
63
            }
64
        }
65
    }
66
67
    public function getDefault()
68
    {
69
        return $this->default;
70
    }
71
}
72