@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | |
78 | 78 | $tokens = $this->tokenizer->tokenize($filename); |
79 | 79 | |
80 | - foreach($tokens as $token) { |
|
81 | - if($this->tokenType->isOperator($token)) { |
|
80 | + foreach ($tokens as $token) { |
|
81 | + if ($this->tokenType->isOperator($token)) { |
|
82 | 82 | $this->operators[] = $token; |
83 | 83 | } |
84 | - else if($this->tokenType->isOperand($token)) { |
|
84 | + else if ($this->tokenType->isOperand($token)) { |
|
85 | 85 | $this->operands[] = $token; |
86 | 86 | } |
87 | 87 | } |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | $this->inventory($filename); |
100 | 100 | $result = new Result; |
101 | 101 | |
102 | - $uniqueOperators = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operators ) ) ); |
|
103 | - $uniqueOperands = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operands ) ) ); |
|
102 | + $uniqueOperators = array_map('unserialize', array_unique(array_map('serialize', $this->operators))); |
|
103 | + $uniqueOperands = array_map('unserialize', array_unique(array_map('serialize', $this->operands))); |
|
104 | 104 | |
105 | 105 | $n1 = sizeof($uniqueOperators, COUNT_NORMAL); |
106 | 106 | $n2 = sizeof($uniqueOperands, COUNT_NORMAL); |
107 | 107 | $N1 = sizeof($this->operators, COUNT_NORMAL); |
108 | 108 | $N2 = sizeof($this->operands, COUNT_NORMAL); |
109 | 109 | |
110 | - if(($n2 == 0)||($N2 == 0)||($n2 == 2)) { |
|
110 | + if (($n2 == 0) || ($N2 == 0) || ($n2 == 2)) { |
|
111 | 111 | // files without operators |
112 | 112 | $V = $n1 = $n2 = $N1 = $N2 = $E = $D = $B = $T = $I = $L = 0; |
113 | 113 | } else { |
114 | 114 | $devAbility = 3000; |
115 | 115 | $N = $N1 + $N2; |
116 | 116 | $n = $n1 + $n2; |
117 | - $V = $N * log($n ,2); |
|
118 | - $L = (2 / max(1,$n1)) * ($n2 / $N2); |
|
117 | + $V = $N * log($n, 2); |
|
118 | + $L = (2 / max(1, $n1)) * ($n2 / $N2); |
|
119 | 119 | $D = ($n1 / 2) * ($N2 / $n2); |
120 | 120 | $E = $V * $D; |
121 | 121 | $B = $V / $devAbility; |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | $result |
127 | 127 | ->setLength($N1 + $N2) |
128 | 128 | ->setVocabulary($n1 + $n2) |
129 | - ->setVolume(round($V,2)) |
|
130 | - ->setDifficulty(round($D,2)) |
|
131 | - ->setEffort(round($E,2)) |
|
129 | + ->setVolume(round($V, 2)) |
|
130 | + ->setDifficulty(round($D, 2)) |
|
131 | + ->setEffort(round($E, 2)) |
|
132 | 132 | ->setLevel(round($L, 2)) |
133 | 133 | ->setBugs(round($B, 2)) |
134 | 134 | ->setTime(round($T)) |
135 | - ->setIntelligentContent(round($I,2)) |
|
135 | + ->setIntelligentContent(round($I, 2)) |
|
136 | 136 | ->setNumberOfOperators($N1) |
137 | 137 | ->setNumberOfOperands($N2) |
138 | 138 | ->setNumberOfUniqueOperators($n1) |
@@ -80,8 +80,7 @@ |
||
80 | 80 | foreach($tokens as $token) { |
81 | 81 | if($this->tokenType->isOperator($token)) { |
82 | 82 | $this->operators[] = $token; |
83 | - } |
|
84 | - else if($this->tokenType->isOperand($token)) { |
|
83 | + } else if($this->tokenType->isOperand($token)) { |
|
85 | 84 | $this->operands[] = $token; |
86 | 85 | } |
87 | 86 | } |
@@ -48,11 +48,11 @@ |
||
48 | 48 | $content = file_get_contents($filename); |
49 | 49 | |
50 | 50 | $cloc = $lloc = 0; |
51 | - foreach($tokens as $token) { |
|
51 | + foreach ($tokens as $token) { |
|
52 | 52 | |
53 | - switch($token->getType()) { |
|
53 | + switch ($token->getType()) { |
|
54 | 54 | case T_STRING: |
55 | - if(';' == $token->getValue()) { |
|
55 | + if (';' == $token->getValue()) { |
|
56 | 56 | $lloc++; |
57 | 57 | } |
58 | 58 | break; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @inheritdoc |
50 | 50 | */ |
51 | 51 | public function asArray() { |
52 | - return array ( |
|
52 | + return array( |
|
53 | 53 | 'loc' => $this->getLoc() |
54 | 54 | ,'logicalLoc' => $this->getLogicalLoc() |
55 | 55 | ); |
@@ -40,12 +40,12 @@ |
||
40 | 40 | { |
41 | 41 | $result = new Result; |
42 | 42 | $result->setMaintainabilityIndexWithoutComment(max( |
43 | - (171 |
|
43 | + (171 |
|
44 | 44 | - (5.2 * \log($rHalstead->getVolume())) |
45 | 45 | - (0.23 * $rMcCabe->getCyclomaticComplexityNumber()) |
46 | 46 | - (16.2 * \log($rLoc->getLogicalLoc())) |
47 | - ) * 100 / 171 |
|
48 | - ,0)); |
|
47 | + ) * 100 / 171 |
|
48 | + ,0)); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | // comment weight |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | |
51 | 51 | // comment weight |
52 | - if($rLoc->getLoc() > 0) { |
|
52 | + if ($rLoc->getLoc() > 0) { |
|
53 | 53 | $CM = $rLoc->getCommentLoc() / $rLoc->getLoc(); |
54 | 54 | $result->setCommentWeight( |
55 | 55 | 50 * sin(sqrt(2.4 * $CM)) |
@@ -60,10 +60,10 @@ |
||
60 | 60 | */ |
61 | 61 | public function setMaintainabilityIndexWithoutComment($maintainabilityIndexWithoutComment) |
62 | 62 | { |
63 | - if(is_infinite($maintainabilityIndexWithoutComment)) { |
|
63 | + if (is_infinite($maintainabilityIndexWithoutComment)) { |
|
64 | 64 | $maintainabilityIndexWithoutComment = 171; |
65 | 65 | } |
66 | - $this->maintainabilityIndexWithoutComment = round($maintainabilityIndexWithoutComment,2); |
|
66 | + $this->maintainabilityIndexWithoutComment = round($maintainabilityIndexWithoutComment, 2); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | /** |
@@ -28,16 +28,16 @@ |
||
28 | 28 | |
29 | 29 | $ac = $cc = $abstractness = 0; |
30 | 30 | |
31 | - foreach($results as $result) { |
|
31 | + foreach ($results as $result) { |
|
32 | 32 | $rOOP = $result->getOOP(); |
33 | - if(is_object($rOOP)) { |
|
33 | + if (is_object($rOOP)) { |
|
34 | 34 | $cc += sizeof($rOOP->getConcreteClasses(), COUNT_NORMAL); |
35 | 35 | $ac += sizeof($rOOP->getAbstractClasses(), COUNT_NORMAL); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | $result = new Result; |
40 | - if($ac + $cc > 0) { |
|
40 | + if ($ac + $cc > 0) { |
|
41 | 41 | $abstractness = round($ac / ($ac + $cc), 2); |
42 | 42 | } |
43 | 43 | $result->setAbstractness($abstractness); |
@@ -28,16 +28,16 @@ |
||
28 | 28 | |
29 | 29 | $ca = $ce = $i = 0; |
30 | 30 | |
31 | - foreach($results as $result) { |
|
31 | + foreach ($results as $result) { |
|
32 | 32 | $r = $result->getCoupling(); |
33 | - if(is_object($r)) { |
|
33 | + if (is_object($r)) { |
|
34 | 34 | $ce += $r->getEfferentCoupling(); |
35 | 35 | $ca += $r->getAfferentCoupling(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | $result = new Result; |
40 | - if($ca + $ce > 0) { |
|
40 | + if ($ca + $ce > 0) { |
|
41 | 41 | $i = round($ce / ($ca + $ce), 2); |
42 | 42 | } |
43 | 43 | $result->setInstability($i); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function execute(array $files) { |
49 | 49 | $fileCoupling = new FileLackOfCohesionOfMethods($this->classMap); |
50 | - foreach($files as $filename) { |
|
50 | + foreach ($files as $filename) { |
|
51 | 51 | $result = $fileCoupling->calculate($filename); |
52 | 52 | $this->collection->get($filename)->setLcom($result); |
53 | 53 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function execute(array $files) { |
49 | 49 | $fileCoupling = new FileLackOfCohesionOfMethods($this->classMap); |
50 | - foreach($files as $filename) { |
|
50 | + foreach ($files as $filename) { |
|
51 | 51 | $result = $fileCoupling->calculate($filename); |
52 | 52 | $this->collection->get($filename)->setLcom($result); |
53 | 53 | } |