1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace TheCodingMachine\WashingMachine\Clover\Analysis; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Represents a method analyzed by clover. |
8
|
|
|
*/ |
9
|
|
|
class Method |
10
|
|
|
{ |
11
|
|
|
// visibility="public" complexity="2" crap="2.03" count="1" |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $methodName; |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $className; |
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $namespace; |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $visibility; |
28
|
|
|
/** |
29
|
|
|
* @var float |
30
|
|
|
*/ |
31
|
|
|
private $complexity; |
32
|
|
|
/** |
33
|
|
|
* @var float |
34
|
|
|
*/ |
35
|
|
|
private $crap; |
36
|
|
|
/** |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
private $count; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $file; |
44
|
|
|
/** |
45
|
|
|
* @var int |
46
|
|
|
*/ |
47
|
|
|
private $line; |
48
|
|
|
|
49
|
|
|
public function __construct(string $methodName, string $className, string $namespace, float $complexity, float $crap, string $visibility = null, int $count = null, string $file = null, int $line = null) |
50
|
|
|
{ |
51
|
|
|
|
52
|
|
|
$this->methodName = $methodName; |
53
|
|
|
$this->className = $className; |
54
|
|
|
$this->namespace = $namespace; |
55
|
|
|
$this->visibility = $visibility; |
56
|
|
|
$this->complexity = $complexity; |
57
|
|
|
$this->crap = $crap; |
58
|
|
|
$this->count = $count; |
59
|
|
|
$this->file = $file; |
60
|
|
|
$this->line = $line; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getMethodName(): string |
67
|
|
|
{ |
68
|
|
|
return $this->methodName; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
|
public function getClassName(): string |
75
|
|
|
{ |
76
|
|
|
return $this->className; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getNamespace(): string |
83
|
|
|
{ |
84
|
|
|
return $this->namespace; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getVisibility(): string |
91
|
|
|
{ |
92
|
|
|
return $this->visibility; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return float |
97
|
|
|
*/ |
98
|
|
|
public function getComplexity(): float |
99
|
|
|
{ |
100
|
|
|
return $this->complexity; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return float |
105
|
|
|
*/ |
106
|
|
|
public function getCrap(): float |
107
|
|
|
{ |
108
|
|
|
return $this->crap; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
|
|
public function getCount(): int |
115
|
|
|
{ |
116
|
|
|
return $this->count; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getFullName() : string |
120
|
|
|
{ |
121
|
|
|
return $this->namespace.'\\'.$this->className.'::'.$this->methodName; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function getShortName() : string |
125
|
|
|
{ |
126
|
|
|
return $this->className.'::'.$this->methodName; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getFile() |
133
|
|
|
{ |
134
|
|
|
return $this->file; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return int |
139
|
|
|
*/ |
140
|
|
|
public function getLine() |
141
|
|
|
{ |
142
|
|
|
return $this->line; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Merges the method passed in parameter in this method. |
147
|
|
|
* Any non null property will override this object property. |
148
|
|
|
* Return a NEW object. |
149
|
|
|
* |
150
|
|
|
* @param Method $method |
151
|
|
|
*/ |
152
|
|
|
public function merge(Method $method): Method |
153
|
|
|
{ |
154
|
|
|
$clone = clone $this; |
155
|
|
|
$clone->visibility = $method->visibility ?? $this->visibility; |
156
|
|
|
$clone->complexity = $method->complexity ?? $this->complexity; |
157
|
|
|
$clone->crap = $method->crap ?? $this->crap; |
158
|
|
|
$clone->count = $method->count ?? $this->count; |
159
|
|
|
$clone->file = $method->file ?? $this->file; |
160
|
|
|
$clone->line = $method->line ?? $this->line; |
161
|
|
|
return $clone; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|