Completed
Pull Request — master (#221)
by personal
04:09
created
src/Hal/Component/Reflected/Klass.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     public function getDependencies($unique = true)
68 68
     {
69 69
         $dependencies = array();
70
-        foreach($this->methods as $method) {
70
+        foreach ($this->methods as $method) {
71 71
             $dependencies = array_merge($dependencies, $method->getDependencies());
72 72
         }
73 73
 
74
-        if($unique) {
74
+        if ($unique) {
75 75
             $dependencies = array_unique($dependencies);
76 76
         }
77 77
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function setIsAbstract($isAbstract)
171 171
     {
172
-        $this->isAbstract = (bool)$isAbstract;
172
+        $this->isAbstract = (bool) $isAbstract;
173 173
         return $this;
174 174
     }
175 175
 
Please login to merge, or discard this patch.
src/Hal/Component/Reflected/Method.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
         $typeResolver = new TypeResolver();
64 64
 
65 65
         $dependencies = array();
66
-        foreach($this->returns as $return) {
67
-            if($typeResolver->isObject($return->getType())) {
66
+        foreach ($this->returns as $return) {
67
+            if ($typeResolver->isObject($return->getType())) {
68 68
                 array_push($dependencies, $return->getType());
69 69
             }
70 70
         }
71
-        foreach($this->arguments as $argument) {
71
+        foreach ($this->arguments as $argument) {
72 72
             array_push($dependencies, $argument->getType());
73 73
         }
74
-        foreach($this->calls as $call) {
74
+        foreach ($this->calls as $call) {
75 75
             array_push($dependencies, $call->getType());
76 76
         }
77 77
 
78
-        if($unique) {
78
+        if ($unique) {
79 79
             $dependencies = array_unique($dependencies);
80 80
         }
81 81
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function setIsStatic($isStatic)
167 167
     {
168
-        $this->isStatic = (bool)$isStatic;
168
+        $this->isStatic = (bool) $isStatic;
169 169
         return $this;
170 170
     }
171 171
 
Please login to merge, or discard this patch.
src/Hal/Metrics/Mood/Abstractness/Abstractness.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
         $ac = $cc = $abstractness = 0;
31 31
 
32
-        foreach($graph->all() as $node) {
32
+        foreach ($graph->all() as $node) {
33 33
             $class = $node->getData();
34
-            if (($class->isAbstract() ||$class->isInterface())) {
34
+            if (($class->isAbstract() || $class->isInterface())) {
35 35
                 $ac++;
36 36
             } else {
37 37
                 $cc++;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         }
40 40
 
41 41
         $result = new Result;
42
-        if($ac + $cc > 0) {
42
+        if ($ac + $cc > 0) {
43 43
             $abstractness = round($ac / ($ac + $cc), 2);
44 44
         }
45 45
         $result->setAbstractness($abstractness);
Please login to merge, or discard this patch.
src/Hal/Metrics/Mood/Instability/Instability.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $ca = $ce = $i = 0;
32 32
 
33 33
         $coupling = new Coupling();
34
-        foreach($graph->all() as $node) {
34
+        foreach ($graph->all() as $node) {
35 35
 
36 36
             $r = $coupling->calculate($node);
37 37
             $ce += $r->getEfferentCoupling();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         }
40 40
 
41 41
         $result = new Result;
42
-        if($ca + $ce > 0) {
42
+        if ($ca + $ce > 0) {
43 43
             $i = round($ce / ($ca + $ce), 2);
44 44
         }
45 45
         $result->setInstability($i);
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/HenryAndKafura/Coupling.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
     public function calculate(Node $node)
29 29
     {
30 30
         $efferent = $afferent = 0;
31
-        foreach($node->getEdges() as $edge) {
31
+        foreach ($node->getEdges() as $edge) {
32 32
 
33
-            if($edge->getFrom()->getKey() == $node->getKey()) {
33
+            if ($edge->getFrom()->getKey() == $node->getKey()) {
34 34
                 // affects
35 35
                 $afferent++;
36 36
             }
37 37
 
38
-            if($edge->getTo()->getKey() == $node->getKey()) {
38
+            if ($edge->getTo()->getKey() == $node->getKey()) {
39 39
                 // receive effects
40 40
                 $efferent++;
41 41
             }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             ->setAfferentCoupling($afferent)
47 47
             ->setEfferentCoupling($efferent);
48 48
 
49
-        if($efferent + $afferent > 0) {
49
+        if ($efferent + $afferent > 0) {
50 50
             $result->setInstability($efferent / ($afferent + $efferent));
51 51
         }
52 52
         return $result;
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/LCOM/LackOfCohesionOfMethods.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
         $graph = new Graph();
31 31
 
32 32
         // attributes in graph are prefixed with '_attr_' string
33
-        foreach($class->getMethods() as $method) {
33
+        foreach ($class->getMethods() as $method) {
34 34
 
35 35
             // avoid getters and setters
36
-            if($method->isGetter() ||$method->isSetter()) {
36
+            if ($method->isGetter() || $method->isSetter()) {
37 37
                 continue;
38 38
             }
39 39
 
40
-            if(null === ($from = $graph->get($method->getName()))) {
40
+            if (null === ($from = $graph->get($method->getName()))) {
41 41
                 $from = new Node($method->getName());
42 42
                 $graph->insert($from);
43 43
             }
44 44
 
45 45
             // calls
46
-            foreach($method->getCalls() as $call) {
46
+            foreach ($method->getCalls() as $call) {
47 47
 
48
-                if(!$call->isItself()) {
48
+                if (!$call->isItself()) {
49 49
                     continue;
50 50
 
51 51
                 }
52 52
 
53
-                if(null === ($to = $graph->get($call->getMethodName()))) {
53
+                if (null === ($to = $graph->get($call->getMethodName()))) {
54 54
                     $to = new Node($call->getMethodName());
55 55
                     $graph->insert($to);
56 56
                 }
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
             }
59 59
 
60 60
             // attributes
61
-            foreach($method->getTokens() as $token) {
62
-                if(preg_match('!\$this\->(\w+)$!', $token, $matches)) {
61
+            foreach ($method->getTokens() as $token) {
62
+                if (preg_match('!\$this\->(\w+)$!', $token, $matches)) {
63 63
                     list(, $attribute) = $matches;
64 64
 
65
-                    if(null === ($to = $graph->get('_attr_' . $attribute))) {
66
-                        $to = new Node('_attr_' . $attribute);
65
+                    if (null === ($to = $graph->get('_attr_'.$attribute))) {
66
+                        $to = new Node('_attr_'.$attribute);
67 67
                         $graph->insert($to);
68 68
                     }
69 69
                     $graph->addEdge($from, $to);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
         // iterate over nodes, and count paths
76 76
         $paths = 0;
77
-        foreach($graph->all() as $node) {
77
+        foreach ($graph->all() as $node) {
78 78
             $paths += $this->traverse($node);
79 79
         }
80 80
 
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
      */
94 94
     private function traverse(Node $node)
95 95
     {
96
-        if($node->visited) {
96
+        if ($node->visited) {
97 97
             return 0;
98 98
         }
99 99
         $node->visited = true;
100 100
 
101
-        foreach($node->getAdjacents() as $adjacent) {
101
+        foreach ($node->getAdjacents() as $adjacent) {
102 102
             $this->traverse($adjacent);
103 103
         }
104 104
 
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Text/Length/Loc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
         // count and remove multi lines comments
33 33
         $cloc = 0;
34
-        if(preg_match_all('!/\*.*?\*/!s', $code, $matches)) {
35
-            foreach($matches[0] as $match) {
36
-                $cloc +=  max(1, sizeof(preg_split('/\r\n|\r|\n/', $match)));
34
+        if (preg_match_all('!/\*.*?\*/!s', $code, $matches)) {
35
+            foreach ($matches[0] as $match) {
36
+                $cloc += max(1, sizeof(preg_split('/\r\n|\r|\n/', $match)));
37 37
             }
38 38
         }
39 39
         $code = preg_replace('!/\*.*?\*/!s', '', $code);
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
         // count and remove empty lines
46 46
         $code = trim(preg_replace('!(^\s*[\r\n])!sm', '', $code));
47
-        $lloc = sizeof(preg_split('/\r\n|\r|\n/', $code)) ;
47
+        $lloc = sizeof(preg_split('/\r\n|\r|\n/', $code));
48 48
 
49 49
         $result = new Result;
50 50
         $result
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Text/Halstead/Halstead.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Component/McCabe/McCabe.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 block discarded – undo
40 40
         $info = new Result;
41 41
 
42 42
         $ccn = 1; // default path
43
-        foreach($class->getTokens() as $token) {
43
+        foreach ($class->getTokens() as $token) {
44 44
 
45
-            switch($token) {
45
+            switch ($token) {
46 46
                 case Token::T_IF:
47 47
                 case Token::T_ELSEIF:
48 48
                 case Token::T_FOREACH:
Please login to merge, or discard this patch.