@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $len = 0; |
50 | 50 | $sy = $dc = $sc = array(); |
51 | 51 | $calculator = new SystemComplexity(); |
52 | - foreach($rOOP->getClasses() as $class) { |
|
52 | + foreach ($rOOP->getClasses() as $class) { |
|
53 | 53 | $r = $calculator->calculate($class); |
54 | 54 | |
55 | 55 | $len += sizeof($class->getMethods(), COUNT_NORMAL); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $sc[] = $r->getTotalStructuralComplexity(); |
59 | 59 | } |
60 | 60 | |
61 | - if($len > 0 &&sizeof($dc, COUNT_NORMAL) > 0) { |
|
61 | + if ($len > 0 && sizeof($dc, COUNT_NORMAL) > 0) { |
|
62 | 62 | $result |
63 | 63 | ->setRelativeStructuralComplexity(round(array_sum($sc) / $len, 2)) |
64 | 64 | ->setRelativeDataComplexity(round(array_sum($dc) / $len, 2)) |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | |
38 | 38 | $sy = $dc = $sc = array(); // in system |
39 | - foreach($class->getMethods() as $method) { |
|
39 | + foreach ($class->getMethods() as $method) { |
|
40 | 40 | $fanout = sizeof($method->getDependencies(), COUNT_NORMAL); |
41 | 41 | $v = sizeof($method->getArguments(), COUNT_NORMAL) + sizeof($method->getReturns(), COUNT_NORMAL); |
42 | 42 |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $map = $this->extractCoupling($result); |
30 | 30 | |
31 | 31 | // instability |
32 | - foreach($map as &$class) { |
|
33 | - if($class->getAfferentCoupling() + $class->getEfferentCoupling() > 0) { |
|
32 | + foreach ($map as &$class) { |
|
33 | + if ($class->getAfferentCoupling() + $class->getEfferentCoupling() > 0) { |
|
34 | 34 | $class->setInstability($class->getEfferentCoupling() / ($class->getAfferentCoupling() + $class->getEfferentCoupling())); |
35 | 35 | } |
36 | 36 | } |
@@ -49,22 +49,22 @@ discard block |
||
49 | 49 | $results = $result->all(); |
50 | 50 | |
51 | 51 | $classes = array(); |
52 | - foreach($results as $result) { |
|
52 | + foreach ($results as $result) { |
|
53 | 53 | $classes = array_merge($classes, $result->getClasses()); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $map = array(); |
57 | - foreach($classes as $class) { |
|
57 | + foreach ($classes as $class) { |
|
58 | 58 | |
59 | - if(!isset($map[$class->getFullname()])) { |
|
59 | + if (!isset($map[$class->getFullname()])) { |
|
60 | 60 | $map[$class->getFullname()] = new Result($class->getFullname()); |
61 | 61 | } |
62 | 62 | |
63 | 63 | $dependencies = $class->getDependencies(); |
64 | 64 | $map[$class->getFullname()]->setEfferentCoupling(sizeof($dependencies, COUNT_NORMAL)); |
65 | 65 | |
66 | - foreach($dependencies as $dependency) { |
|
67 | - if(!isset($map[$dependency])) { |
|
66 | + foreach ($dependencies as $dependency) { |
|
67 | + if (!isset($map[$dependency])) { |
|
68 | 68 | $map[$dependency] = new Result($dependency); |
69 | 69 | } |
70 | 70 | $map[$dependency]->setAfferentCoupling($map[$dependency]->getAfferentCoupling() + 1); |
@@ -54,21 +54,21 @@ |
||
54 | 54 | $result = new Result($filename); |
55 | 55 | |
56 | 56 | // case of file doesn't contain any class |
57 | - if(null === $rOOP) { |
|
57 | + if (null === $rOOP) { |
|
58 | 58 | return $result; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $instability = $ce = $ca = 0; |
62 | 62 | |
63 | 63 | $classes = $rOOP->getClasses(); |
64 | - foreach($classes as $declaredClass) { |
|
64 | + foreach ($classes as $declaredClass) { |
|
65 | 65 | $declaredClassCoupling = $this->couplingMap->get($declaredClass->getFullname()); |
66 | 66 | |
67 | 67 | $ce += $declaredClassCoupling->getEfferentCoupling(); |
68 | 68 | $ca += $declaredClassCoupling->getAfferentCoupling(); |
69 | 69 | } |
70 | 70 | |
71 | - if($ca + $ce > 0) { |
|
71 | + if ($ca + $ce > 0) { |
|
72 | 72 | $instability = $ce / ($ca + $ce); |
73 | 73 | } |
74 | 74 |
@@ -50,9 +50,9 @@ |
||
50 | 50 | $n = 0; |
51 | 51 | $lcom = new LackOfCohesionOfMethods(); |
52 | 52 | |
53 | - foreach($rOOP->getClasses() as $class) { |
|
53 | + foreach ($rOOP->getClasses() as $class) { |
|
54 | 54 | |
55 | - if($class instanceof ReflectedInterface) { |
|
55 | + if ($class instanceof ReflectedInterface) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $methodsToInspect = $class->getMethods(); |
35 | 35 | |
36 | 36 | $toSkip = array(); |
37 | - foreach($methodsToInspect as $method) { |
|
37 | + foreach ($methodsToInspect as $method) { |
|
38 | 38 | |
39 | - if(in_array($method->getName(), $toSkip)) { |
|
39 | + if (in_array($method->getName(), $toSkip)) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
43 | - if($method->isSetter() ||$method->isGetter()) { |
|
43 | + if ($method->isSetter() || $method->isGetter()) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | // foreach directly linked methods, recurs |
80 | 80 | $methods = $class->getMethods(); |
81 | - foreach($linked as $link) { |
|
82 | - if(!isset( $methods[$link])) { |
|
81 | + foreach ($linked as $link) { |
|
82 | + if (!isset($methods[$link])) { |
|
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | $linked = array_merge($linked, $this->getLinkedMethods($class, $methods[$link], $toSkip)); |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | $linked = array(); |
100 | 100 | |
101 | 101 | // A calls B |
102 | - if(preg_match_all('!\\$this\\->(\w*?)\\(!im', $method->getContent(), $matches)) { |
|
102 | + if (preg_match_all('!\\$this\\->(\w*?)\\(!im', $method->getContent(), $matches)) { |
|
103 | 103 | list(, $linked) = $matches; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // B calls A |
107 | - foreach($class->getMethods() as $otherMethod) { |
|
107 | + foreach ($class->getMethods() as $otherMethod) { |
|
108 | 108 | $otherCalls = array(); |
109 | - if(preg_match_all('!\\$this\\->(\w*?)\\(!im', $otherMethod->getContent(), $matches)) { |
|
109 | + if (preg_match_all('!\\$this\\->(\w*?)\\(!im', $otherMethod->getContent(), $matches)) { |
|
110 | 110 | list(, $otherCalls) = $matches; |
111 | 111 | } |
112 | 112 | |
113 | - if(in_array($method->getName(), $otherCalls)) { |
|
113 | + if (in_array($method->getName(), $otherCalls)) { |
|
114 | 114 | array_push($linked, $otherMethod->getName()); |
115 | 115 | } |
116 | 116 | } |
@@ -128,29 +128,29 @@ discard block |
||
128 | 128 | |
129 | 129 | $linked = array(); |
130 | 130 | $members = array(); |
131 | - if(preg_match_all('!\\$this\\->([\w\\(]+)!im', $method->getContent(), $matches)) { |
|
131 | + if (preg_match_all('!\\$this\\->([\w\\(]+)!im', $method->getContent(), $matches)) { |
|
132 | 132 | list(, $members) = $matches; |
133 | 133 | } |
134 | 134 | |
135 | 135 | |
136 | 136 | // search in other methods if they share attribute |
137 | - foreach($class->getMethods() as $otherMethod) { |
|
137 | + foreach ($class->getMethods() as $otherMethod) { |
|
138 | 138 | $otherMembers = array(); |
139 | - if(preg_match_all('!\\$this\\->([\w\\(]+)!im', $otherMethod->getContent(), $matches)) { |
|
139 | + if (preg_match_all('!\\$this\\->([\w\\(]+)!im', $otherMethod->getContent(), $matches)) { |
|
140 | 140 | list(, $otherMembers) = $matches; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $intersect = array_intersect($members, $otherMembers); |
144 | 144 | |
145 | 145 | // remove calls (members and calls are mixed : regex is too complex to be read) |
146 | - foreach($intersect as $k => $name) { |
|
147 | - if(preg_match('!\($!', $name)) { |
|
146 | + foreach ($intersect as $k => $name) { |
|
147 | + if (preg_match('!\($!', $name)) { |
|
148 | 148 | unset($intersect[$k]); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | - if(sizeof($intersect, COUNT_NORMAL) > 0) { |
|
153 | + if (sizeof($intersect, COUNT_NORMAL) > 0) { |
|
154 | 154 | |
155 | 155 | array_push($linked, $otherMethod->getName()); |
156 | 156 | } |
@@ -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 | ); |