1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Jean-François Lépine <https://twitter.com/Halleck45> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Hal\Component\Result; |
11
|
|
|
use Hal\Component\OOP\Extractor\Result; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* ResultSet |
16
|
|
|
* |
17
|
|
|
* @author Jean-François Lépine <https://twitter.com/Halleck45> |
18
|
|
|
*/ |
19
|
|
|
class ResultSet implements ExportableInterface, ResultSetInterface { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Filename |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $filename; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Halstead Result |
30
|
|
|
* @var \Hal\Metrics\Complexity\Text\Halstead\Result |
31
|
|
|
*/ |
32
|
|
|
private $halstead; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* LOC Result |
36
|
|
|
* |
37
|
|
|
* @var \Hal\Metrics\Complexity\Text\Length\Result |
38
|
|
|
*/ |
39
|
|
|
private $loc; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* McCabe Result |
43
|
|
|
* |
44
|
|
|
* @var \Hal\Metrics\Complexity\Component\McCabe\Result |
45
|
|
|
*/ |
46
|
|
|
private $mcCabe; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Myer's interval result |
50
|
|
|
* |
51
|
|
|
* @var \Hal\Metrics\Complexity\Component\Myer\Result |
52
|
|
|
*/ |
53
|
|
|
private $myer; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Maintainability Result |
57
|
|
|
* |
58
|
|
|
* @var \Hal\Metrics\Design\Component\MaintainabilityIndex\Result |
59
|
|
|
*/ |
60
|
|
|
private $maintainabilityIndex; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Coupling |
64
|
|
|
* |
65
|
|
|
* @var \Hal\Metrics\Complexity\Structural\HenryAndKafura\Result |
66
|
|
|
*/ |
67
|
|
|
private $coupling; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Infos about OOP |
71
|
|
|
* |
72
|
|
|
* @var Result |
73
|
|
|
*/ |
74
|
|
|
private $oop; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Lack of cohesion of methods |
78
|
|
|
* |
79
|
|
|
* @var |
80
|
|
|
*/ |
81
|
|
|
private $lcom; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* System complexity result |
85
|
|
|
* |
86
|
|
|
* @var \Hal\Metrics\Complexity\Structural\CardAndAgresti\Result |
87
|
|
|
*/ |
88
|
|
|
private $systemComplexity; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Constructor |
92
|
|
|
* |
93
|
|
|
* @param string $filename |
94
|
|
|
*/ |
95
|
|
|
public function __construct($filename) { |
96
|
|
|
$this->filename = (string) $filename; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritdoc |
101
|
|
|
*/ |
102
|
|
|
public function getName() { |
103
|
|
|
return $this->filename; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @inheritdoc |
108
|
|
|
*/ |
109
|
|
|
public function asArray() { |
110
|
|
|
return array_merge( |
111
|
|
|
array( |
112
|
|
|
'filename' => $this->getFilename() |
113
|
|
|
, 'name' => $this->getName() |
114
|
|
|
) |
115
|
|
|
, $this->getLoc() ? $this->getLoc()->asArray() : array() |
116
|
|
|
, $this->getHalstead() ? $this->getHalstead()->asArray() : array() |
117
|
|
|
, $this->getMaintainabilityIndex() ? $this->getMaintainabilityIndex()->asArray() : array() |
118
|
|
|
, $this->getCoupling() ? $this->getCoupling()->asArray() : array() |
119
|
|
|
, $this->getOop() ? $this->getOop()->asArray() : array() |
120
|
|
|
, $this->getMcCabe() ? $this->getMcCabe()->asArray() : array() |
121
|
|
|
, $this->getMyer() ? $this->getMyer()->asArray() : array() |
122
|
|
|
, $this->getLcom() ? $this->getLcom()->asArray() : array() |
123
|
|
|
, $this->getSystemComplexity() ? $this->getSystemComplexity()->asArray() : array() |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param \Hal\Metrics\Complexity\Text\Halstead\Result $halstead |
129
|
|
|
* @return $this |
130
|
|
|
*/ |
131
|
|
|
public function setHalstead(\Hal\Metrics\Complexity\Text\Halstead\Result $halstead) |
132
|
|
|
{ |
133
|
|
|
$this->halstead = $halstead; |
134
|
|
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return \Hal\Metrics\Complexity\Text\Halstead\Result |
139
|
|
|
*/ |
140
|
|
|
public function getHalstead() |
141
|
|
|
{ |
142
|
|
|
return $this->halstead; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param \Hal\Metrics\Complexity\Text\Length\Result $loc |
147
|
|
|
* @return $this |
148
|
|
|
*/ |
149
|
|
|
public function setLoc(\Hal\Metrics\Complexity\Text\Length\Result $loc) |
150
|
|
|
{ |
151
|
|
|
$this->loc = $loc; |
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return \Hal\Metrics\Complexity\Text\Length\Result |
157
|
|
|
*/ |
158
|
|
|
public function getLoc() |
159
|
|
|
{ |
160
|
|
|
return $this->loc; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param \Hal\Metrics\Complexity\Component\McCabe\Result $mcCabe |
166
|
|
|
* @return $this |
167
|
|
|
*/ |
168
|
|
|
public function setMcCabe(\Hal\Metrics\Complexity\Component\McCabe\Result $mcCabe) |
169
|
|
|
{ |
170
|
|
|
$this->mcCabe = $mcCabe; |
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return \Hal\Metrics\Complexity\Component\McCabe\Result |
176
|
|
|
*/ |
177
|
|
|
public function getMcCabe() |
178
|
|
|
{ |
179
|
|
|
return $this->mcCabe; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param \Hal\Metrics\Complexity\Component\Myer\Result $myer |
184
|
|
|
* @return $this |
185
|
|
|
*/ |
186
|
|
|
public function setMyer($myer) |
187
|
|
|
{ |
188
|
|
|
$this->myer = $myer; |
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return \Hal\Metrics\Complexity\Component\Myer\Result |
194
|
|
|
*/ |
195
|
|
|
public function getMyer() |
196
|
|
|
{ |
197
|
|
|
return $this->myer; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param \Hal\Metrics\Design\Component\MaintainabilityIndex\Result $maintainabilityIndex |
202
|
|
|
* @return $this |
203
|
|
|
*/ |
204
|
|
|
public function setMaintainabilityIndex(\Hal\Metrics\Design\Component\MaintainabilityIndex\Result $maintainabilityIndex) |
205
|
|
|
{ |
206
|
|
|
$this->maintainabilityIndex = $maintainabilityIndex; |
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @return \Hal\Metrics\Design\Component\MaintainabilityIndex\Result |
212
|
|
|
*/ |
213
|
|
|
public function getMaintainabilityIndex() |
214
|
|
|
{ |
215
|
|
|
return $this->maintainabilityIndex; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Get filename associated to the result set |
220
|
|
|
* |
221
|
|
|
* @return string |
222
|
|
|
*/ |
223
|
|
|
public function getFilename() |
224
|
|
|
{ |
225
|
|
|
return $this->filename; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param \Hal\Metrics\Complexity\Structural\HenryAndKafura\Result $coupling |
230
|
|
|
* @return $this |
231
|
|
|
*/ |
232
|
|
|
public function setCoupling($coupling) |
233
|
|
|
{ |
234
|
|
|
$this->coupling = $coupling; |
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return \Hal\Metrics\Complexity\Structural\HenryAndKafura\Result |
240
|
|
|
*/ |
241
|
|
|
public function getCoupling() |
242
|
|
|
{ |
243
|
|
|
return $this->coupling; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param \Hal\Component\OOP\Extractor\Result $oop |
248
|
|
|
* @return $this |
249
|
|
|
*/ |
250
|
|
|
public function setOop($oop) |
251
|
|
|
{ |
252
|
|
|
$this->oop = $oop; |
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @return \Hal\Component\OOP\Extractor\Result |
258
|
|
|
*/ |
259
|
|
|
public function getOop() |
260
|
|
|
{ |
261
|
|
|
return $this->oop; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param \Hal\Metrics\Complexity\Structural\LCOM\Result $lcom |
266
|
|
|
*/ |
267
|
|
|
public function setLcom(\Hal\Metrics\Complexity\Structural\LCOM\Result $lcom) |
268
|
|
|
{ |
269
|
|
|
$this->lcom = $lcom; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @return \Hal\Metrics\Complexity\Structural\LCOM\Result |
274
|
|
|
*/ |
275
|
|
|
public function getLcom() |
276
|
|
|
{ |
277
|
|
|
return $this->lcom; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @param \Hal\Metrics\Complexity\Structural\CardAndAgresti\Result $systemComplexity |
282
|
|
|
* @return $this |
283
|
|
|
*/ |
284
|
|
|
public function setSystemComplexity(\Hal\Metrics\Complexity\Structural\CardAndAgresti\Result $systemComplexity) |
285
|
|
|
{ |
286
|
|
|
$this->systemComplexity = $systemComplexity; |
287
|
|
|
return $this; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* @return \Hal\Metrics\Complexity\Structural\CardAndAgresti\Result |
292
|
|
|
*/ |
293
|
|
|
public function getSystemComplexity() |
294
|
|
|
{ |
295
|
|
|
return $this->systemComplexity; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
|
299
|
|
|
|
300
|
|
|
} |