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\Metrics\Complexity\Structural\CardAndAgresti; |
11
|
|
|
use Hal\Component\Result\ExportableInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Representation of McCaybe measure |
15
|
|
|
* |
16
|
|
|
* @author Jean-François Lépine <https://twitter.com/Halleck45> |
17
|
|
|
*/ |
18
|
|
|
class Result implements ExportableInterface { |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Relative system complexity |
24
|
|
|
* |
25
|
|
|
* Relative system complexity RSYSC = average(SC + DC) over all procedures |
26
|
|
|
* |
27
|
|
|
* @var integer |
28
|
|
|
*/ |
29
|
|
|
private $relativeSystemComplexity = 0; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Total Data complexity (internal) |
33
|
|
|
* |
34
|
|
|
* Total system complexity SYSC = sum(SC + DC) over all procedures |
35
|
|
|
* |
36
|
|
|
* @var integer |
37
|
|
|
*/ |
38
|
|
|
private $totalSystemComplexity = 0; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Relative Data complexity (internal) |
42
|
|
|
* |
43
|
|
|
* @var integer |
44
|
|
|
*/ |
45
|
|
|
private $relativeDataComplexity = 0; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Relative structural complexity (external) |
49
|
|
|
* |
50
|
|
|
* @var integer |
51
|
|
|
*/ |
52
|
|
|
private $relativeStructuralComplexity = 0; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Total Data complexity (internal) |
56
|
|
|
* |
57
|
|
|
* @var integer |
58
|
|
|
*/ |
59
|
|
|
private $totalDataComplexity = 0; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Total structural complexity (external) |
63
|
|
|
* |
64
|
|
|
* @var integer |
65
|
|
|
*/ |
66
|
|
|
private $totalStructuralComplexity = 0; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritdoc |
70
|
|
|
*/ |
71
|
|
|
public function asArray() { |
72
|
|
|
return array( |
73
|
|
|
'sysc' => $this->getTotalSystemComplexity() |
74
|
|
|
, 'rsysc' => $this->getRelativeSystemComplexity() |
75
|
|
|
, 'dc' => $this->getTotalDataComplexity() |
76
|
|
|
, 'rdc' => $this->getRelativeDataComplexity() |
77
|
|
|
, 'sc' => $this->getTotalStructuralComplexity() |
78
|
|
|
, 'rsc' => $this->getRelativeStructuralComplexity() |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param int $relativeSystemComplexity |
84
|
|
|
* @return $this |
85
|
|
|
*/ |
86
|
|
|
public function setRelativeSystemComplexity($relativeSystemComplexity) |
87
|
|
|
{ |
88
|
|
|
$this->relativeSystemComplexity = $relativeSystemComplexity; |
89
|
|
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return int |
94
|
|
|
*/ |
95
|
|
|
public function getRelativeSystemComplexity() |
96
|
|
|
{ |
97
|
|
|
return $this->relativeSystemComplexity; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param int $totalSystemComplexity |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
|
|
public function setTotalSystemComplexity($totalSystemComplexity) |
105
|
|
|
{ |
106
|
|
|
$this->totalSystemComplexity = $totalSystemComplexity; |
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return int |
112
|
|
|
*/ |
113
|
|
|
public function getTotalSystemComplexity() |
114
|
|
|
{ |
115
|
|
|
return $this->totalSystemComplexity; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param int $relativeDataComplexity |
120
|
|
|
* @return $this |
121
|
|
|
*/ |
122
|
|
|
public function setRelativeDataComplexity($relativeDataComplexity) |
123
|
|
|
{ |
124
|
|
|
$this->relativeDataComplexity = $relativeDataComplexity; |
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return int |
130
|
|
|
*/ |
131
|
|
|
public function getRelativeDataComplexity() |
132
|
|
|
{ |
133
|
|
|
return $this->relativeDataComplexity; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param int $relativeStructuralComplexity |
138
|
|
|
* @return $this |
139
|
|
|
*/ |
140
|
|
|
public function setRelativeStructuralComplexity($relativeStructuralComplexity) |
141
|
|
|
{ |
142
|
|
|
$this->relativeStructuralComplexity = $relativeStructuralComplexity; |
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return int |
148
|
|
|
*/ |
149
|
|
|
public function getRelativeStructuralComplexity() |
150
|
|
|
{ |
151
|
|
|
return $this->relativeStructuralComplexity; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param int $totalDataComplexity |
156
|
|
|
* @return $this |
157
|
|
|
*/ |
158
|
|
|
public function setTotalDataComplexity($totalDataComplexity) |
159
|
|
|
{ |
160
|
|
|
$this->totalDataComplexity = $totalDataComplexity; |
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return int |
166
|
|
|
*/ |
167
|
|
|
public function getTotalDataComplexity() |
168
|
|
|
{ |
169
|
|
|
return $this->totalDataComplexity; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param int $totalStructuralComplexity |
174
|
|
|
* @return $this |
175
|
|
|
*/ |
176
|
|
|
public function setTotalStructuralComplexity($totalStructuralComplexity) |
177
|
|
|
{ |
178
|
|
|
$this->totalStructuralComplexity = $totalStructuralComplexity; |
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return int |
184
|
|
|
*/ |
185
|
|
|
public function getTotalStructuralComplexity() |
186
|
|
|
{ |
187
|
|
|
return $this->totalStructuralComplexity; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
|
191
|
|
|
|
192
|
|
|
|
193
|
|
|
|
194
|
|
|
} |