|
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\HenryAndKafura; |
|
11
|
|
|
use Hal\Component\Result\ExportableInterface; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Represents coupling (for one class) |
|
16
|
|
|
* |
|
17
|
|
|
* @author Jean-François Lépine <https://twitter.com/Halleck45> |
|
18
|
|
|
*/ |
|
19
|
|
|
class Result implements ExportableInterface { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
private $name; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var int |
|
28
|
|
|
*/ |
|
29
|
|
|
private $afferentCoupling = 0; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var int |
|
33
|
|
|
*/ |
|
34
|
|
|
private $efferentCoupling = 0; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var int |
|
38
|
|
|
*/ |
|
39
|
|
|
private $instability = 0; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Constructor |
|
43
|
|
|
* |
|
44
|
|
|
* @param $name |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct($name) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->name = (string) $name; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritdoc |
|
53
|
|
|
*/ |
|
54
|
|
|
public function asArray() |
|
55
|
|
|
{ |
|
56
|
|
|
return array( |
|
57
|
|
|
'instability' => round($this->getInstability(), 2) |
|
58
|
|
|
, 'afferentCoupling' => $this->getAfferentCoupling() |
|
59
|
|
|
, 'efferentCoupling' => $this->getEfferentCoupling() |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param int $afferentCoupling |
|
66
|
|
|
* @return $this |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setAfferentCoupling($afferentCoupling) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->afferentCoupling = $afferentCoupling; |
|
71
|
|
|
return $this; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return int |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getAfferentCoupling() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->afferentCoupling; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param int $efferentCoupling |
|
84
|
|
|
* @return $this |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setEfferentCoupling($efferentCoupling) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->efferentCoupling = $efferentCoupling; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return int |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getEfferentCoupling() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->efferentCoupling; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param int $instability |
|
102
|
|
|
* @return $this |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setInstability($instability) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->instability = $instability; |
|
107
|
|
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return int |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getInstability() |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->instability; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getName() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->name; |
|
124
|
|
|
} |
|
125
|
|
|
} |