@@ -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 | } |
@@ -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 | ); |
@@ -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 | ); |
@@ -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 | ); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | chdir(__DIR__); |
3 | 3 | |
4 | 4 | if (!file_exists('vendor/autoload.php')) { |
5 | - echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL; |
|
5 | + echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!'.PHP_EOL; |
|
6 | 6 | exit(1); |
7 | 7 | } |
8 | 8 | |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | $files = array_merge(rglob('*.php'), rglob('*.twig'), rglob('*.json'), rglob('*.pp')); |
20 | 20 | $exclude = '!(.git)|(.svn)|(bin)|(tests)|(Tests)|(phpmetrics)!'; |
21 | -foreach($files as $file) { |
|
22 | - if(preg_match($exclude, $file)) continue; |
|
21 | +foreach ($files as $file) { |
|
22 | + if (preg_match($exclude, $file)) continue; |
|
23 | 23 | $path = str_replace(__DIR__.'/', '', $file); |
24 | 24 | $phar->addFromString($path, file_get_contents($file)); |
25 | 25 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | chmod($filename, 0755); |
52 | 52 | |
53 | -function rglob($pattern='*', $flags = 0, $path='') |
|
53 | +function rglob($pattern = '*', $flags = 0, $path = '') |
|
54 | 54 | { |
55 | - $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); |
|
56 | - $files=glob($path.$pattern, $flags); |
|
57 | - foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); } |
|
55 | + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); |
|
56 | + $files = glob($path.$pattern, $flags); |
|
57 | + foreach ($paths as $path) { $files = array_merge($files, rglob($pattern, $flags, $path)); } |
|
58 | 58 | return $files; |
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | { |
31 | 31 | $end = sizeof($tokens, COUNT_NORMAL); |
32 | 32 | $value = ''; |
33 | - while($startingToken < $end) { |
|
33 | + while ($startingToken < $end) { |
|
34 | 34 | $token = $tokens[$startingToken]; |
35 | - if(in_array($token->getValue(), $delimiters)) { |
|
35 | + if (in_array($token->getValue(), $delimiters)) { |
|
36 | 36 | return $value; |
37 | 37 | } |
38 | 38 | $value .= $token->getValue(); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | public function getPrevious(&$startingToken, TokenCollection $tokens) |
53 | 53 | { |
54 | 54 | $p = $startingToken - 1; |
55 | - for($i = $p ; $i > 0; $i--) { |
|
56 | - if(T_WHITESPACE !== $tokens[$i]->getType()) { |
|
55 | + for ($i = $p; $i > 0; $i--) { |
|
56 | + if (T_WHITESPACE !== $tokens[$i]->getType()) { |
|
57 | 57 | return $tokens[$i]; |
58 | 58 | } |
59 | 59 | } |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | $openBrace = 0; |
89 | 89 | $start = null; |
90 | 90 | $len = sizeof($tokens); |
91 | - for($i = $startingToken; $i < $len; $i++) { |
|
91 | + for ($i = $startingToken; $i < $len; $i++) { |
|
92 | 92 | $token = $tokens[$i]; |
93 | - if(T_STRING == $token->getType()) { |
|
94 | - switch($token->getValue()) { |
|
93 | + if (T_STRING == $token->getType()) { |
|
94 | + switch ($token->getValue()) { |
|
95 | 95 | case '{': |
96 | 96 | $openBrace++; |
97 | - if(is_null($start)) { |
|
97 | + if (is_null($start)) { |
|
98 | 98 | $start = $startingToken = $i + 1; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case '}': |
102 | 102 | $openBrace--; |
103 | - if($openBrace <= 0) { |
|
103 | + if ($openBrace <= 0) { |
|
104 | 104 | return $i; |
105 | 105 | } |
106 | 106 | break; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getExtendPosition(TokenCollection $tokens, $startingToken) |
121 | 121 | { |
122 | - for($i = $startingToken; $i > 0; $i--) { |
|
122 | + for ($i = $startingToken; $i > 0; $i--) { |
|
123 | 123 | $token = $tokens[$i]; |
124 | 124 | if ($token->getValue() === 'extends') { |
125 | 125 | return $i; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function getClassNamePosition(TokenCollection $tokens) |
137 | 137 | { |
138 | 138 | $len = sizeof($tokens); |
139 | - for($i = 0; $i < $len; $i++) { |
|
139 | + for ($i = 0; $i < $len; $i++) { |
|
140 | 140 | $token = $tokens[$i]; |
141 | 141 | if ($token->getValue() === 'class') { |
142 | 142 | return $i; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getPositionOfPrevious($tokenType, $startingToken, TokenCollection $tokens) |
157 | 157 | { |
158 | - for($i = $startingToken; $i > 0; $i--) { |
|
159 | - if($tokenType == $tokens->get($i)->getType()) { |
|
158 | + for ($i = $startingToken; $i > 0; $i--) { |
|
159 | + if ($tokenType == $tokens->get($i)->getType()) { |
|
160 | 160 | return $i; |
161 | 161 | } |
162 | 162 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | public function getPositionOfNext($tokenType, $startingToken, TokenCollection $tokens) |
175 | 175 | { |
176 | 176 | $len = sizeof($tokens); |
177 | - for($i = $startingToken; $i < $len; $i++) { |
|
178 | - if($tokenType == $tokens->get($i)->getType()) { |
|
177 | + for ($i = $startingToken; $i < $len; $i++) { |
|
178 | + if ($tokenType == $tokens->get($i)->getType()) { |
|
179 | 179 | return $i; |
180 | 180 | } |
181 | 181 | } |