@@ -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 |
@@ -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 | |
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 | /** |
@@ -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 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | /** |
60 | 60 | * Inventories tokens |
61 | 61 | * |
62 | - * @param array $tokens |
|
62 | + * @param \SplFixedArray $tokens |
|
63 | 63 | * @return $this |
64 | 64 | */ |
65 | 65 | private function inventory($tokens) |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | { |
67 | 67 | $this->operators = $this->operands = array(); |
68 | 68 | |
69 | - foreach($tokens as $token) { |
|
70 | - if($this->tokenType->isOperator($token)) { |
|
69 | + foreach ($tokens as $token) { |
|
70 | + if ($this->tokenType->isOperator($token)) { |
|
71 | 71 | $this->operators[] = $token; |
72 | 72 | } |
73 | - else if($this->tokenType->isOperand($token)) { |
|
73 | + else if ($this->tokenType->isOperand($token)) { |
|
74 | 74 | $this->operands[] = $token; |
75 | 75 | } |
76 | 76 | } |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | $this->inventory($class->getTokens()); |
94 | 94 | $result = new Result; |
95 | 95 | |
96 | - $uniqueOperators = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operators ) ) ); |
|
97 | - $uniqueOperands = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operands ) ) ); |
|
96 | + $uniqueOperators = array_map('unserialize', array_unique(array_map('serialize', $this->operators))); |
|
97 | + $uniqueOperands = array_map('unserialize', array_unique(array_map('serialize', $this->operands))); |
|
98 | 98 | |
99 | 99 | $n1 = sizeof($uniqueOperators, COUNT_NORMAL); |
100 | 100 | $n2 = sizeof($uniqueOperands, COUNT_NORMAL); |
101 | 101 | $N1 = sizeof($this->operators, COUNT_NORMAL); |
102 | 102 | $N2 = sizeof($this->operands, COUNT_NORMAL); |
103 | 103 | |
104 | - if(($n2 == 0)||($N2 == 0)) { |
|
104 | + if (($n2 == 0) || ($N2 == 0)) { |
|
105 | 105 | // files without operators |
106 | 106 | $V = $n1 = $n2 = $N1 = $N2 = $E = $D = $B = $T = $I = $L = 0; |
107 | 107 | } else { |
108 | 108 | $devAbility = 3000; |
109 | 109 | $N = $N1 + $N2; |
110 | 110 | $n = $n1 + $n2; |
111 | - $V = $N * log($n ,2); |
|
112 | - $L = (2 / max(1,$n1)) * ($n2 / $N2); |
|
111 | + $V = $N * log($n, 2); |
|
112 | + $L = (2 / max(1, $n1)) * ($n2 / $N2); |
|
113 | 113 | $D = ($n1 / 2) * ($N2 / $n2); |
114 | 114 | $E = $V * $D; |
115 | 115 | $B = $V / $devAbility; |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | $result |
121 | 121 | ->setLength($N1 + $N2) |
122 | 122 | ->setVocabulary($n1 + $n2) |
123 | - ->setVolume(round($V,2)) |
|
124 | - ->setDifficulty(round($D,2)) |
|
125 | - ->setEffort(round($E,2)) |
|
123 | + ->setVolume(round($V, 2)) |
|
124 | + ->setDifficulty(round($D, 2)) |
|
125 | + ->setEffort(round($E, 2)) |
|
126 | 126 | ->setLevel(round($L, 2)) |
127 | 127 | ->setBugs(round($B, 2)) |
128 | 128 | ->setTime(round($T)) |
129 | - ->setIntelligentContent(round($I,2)) |
|
129 | + ->setIntelligentContent(round($I, 2)) |
|
130 | 130 | ->setNumberOfOperators($N1) |
131 | 131 | ->setNumberOfOperands($N2) |
132 | 132 | ->setNumberOfUniqueOperators($n1) |