ParameterInformation::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace DicDoc;
3
4
/**
5
 * Class ParameterInformation
6
 *
7
 * @package DicDoc
8
 */
9
class ParameterInformation
10
{
11
12
    /**
13
     * @var string
14
     */
15
    public $className;
16
    /**
17
     * @var string
18
     */
19
    public $shortClassName;
20
    /**
21
     * @var string
22
     */
23
    public $type;
24
25
    /**
26
     * @var array
27
     */
28
    public $implements = [];
29
30
31
    /**
32
     * ParameterInformation constructor.
33
     *
34
     * @param $param
35
     */
36
    public function __construct($param)
37
    {
38
        $this->type = gettype($param);
39
        if ($this->isObject()) {
40
            $this->className = get_class($param);
41
            $reflection = new \ReflectionClass($this->className);
42
43
            $this->shortClassName = $reflection->getShortName();
44
45
            foreach (class_implements($this->className) as $interface) {
46
                //I don't want framework interfaces
47
                if (explode("\\", $interface)[0] == explode("\\", $this->className)[0]) {
48
                    $this->implements[] = $interface;
49
                }
50
            }
51
52
53
        }
54
55
    }
56
57
    /**
58
     * @return array
59
     */
60
    public function getImplements()
61
    {
62
        return $this->implements;
63
    }
64
65
    /**
66
     * @return mixed
67
     */
68
    public function getShortClassName()
69
    {
70
        return $this->shortClassName;
71
    }
72
73
    /**
74
     * @return mixed
75
     */
76
    public function getType()
77
    {
78
        return $this->type;
79
    }
80
81
82
    /**
83
     * @return string
84
     */
85
    public function getClassName()
86
    {
87
        return $this->className;
88
    }
89
90
    public function isObject()
91
    {
92
        return $this->type == "object";
93
    }
94
95
}