Completed
Pull Request — master (#213)
by Théo
08:21
created
src/Hal/Component/Token/TokenCollectionCompatibility.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function decorate(array $tokens)
25 25
     {
26
-        if(-1 !== version_compare(PHP_VERSION, '7.0.0')) {
26
+        if (-1 !== version_compare(PHP_VERSION, '7.0.0')) {
27 27
             return $tokens;
28 28
         }
29 29
 
30 30
         $previous = null;
31
-        foreach($tokens as $index => &$token) {
31
+        foreach ($tokens as $index => &$token) {
32 32
 
33 33
             // coalesce operator
34
-            if(T_STRING == $token->getType()&&'?' == $token->getValue()
34
+            if (T_STRING == $token->getType() && '?' == $token->getValue()
35 35
                 && $index > 0
36
-                && T_STRING == $previous->getType()&&'?' == $previous->getValue()
36
+                && T_STRING == $previous->getType() && '?' == $previous->getValue()
37 37
             ) {
38 38
                 unset($tokens[$index]);
39 39
                 $tokens[$index - 1] = new Token(array(T_COALESCE, T_COALESCE));
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
             // spaceship operator
45
-            if($index > 2
45
+            if ($index > 2
46 46
                 && T_STRING == $tokens[$index]->getType() && '>' === $tokens[$index]->getValue()
47 47
                 && T_IS_SMALLER_OR_EQUAL == $previous->getType()
48 48
             ) {
Please login to merge, or discard this patch.
src/Hal/Component/Token/TokenType.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @var array
105 105
      */
106 106
     private $operatorsStrings = array(
107
-        ';', '*', '/', '%', '-','+'
107
+        ';', '*', '/', '%', '-', '+'
108 108
     , '!', '!=', '%', '%=', '&', '&&', '||', '&=', '(', ')'
109 109
         /*, '{', '}'*/, '[', ']', '*', '*=', '+', '++', '+=', ','
110 110
     , '-', '--', '-=->', '.', '...', '/', '/=', ':', '::'
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     private $byPass = array(
122 122
         '{', '}' // in PHP, these case are counted with T_IF, '(', ...
123
-    , ')' , '('   // we count only the first (
123
+    , ')', '('   // we count only the first (
124 124
     , ','
125 125
     );
126 126
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * Constructor
129 129
      */
130 130
     public function __construct() {
131
-        if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
131
+        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
132 132
             $this->operators = array_merge($this->operators, array(
133 133
                 T_INSTEADOF
134 134
             , T_TRAIT_C
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 
142 142
         // performance : key will be equals to it value
143 143
         $this->operands = array_combine($this->operands, $this->operands);
144
-        $this->operators= array_combine($this->operators, $this->operators);
144
+        $this->operators = array_combine($this->operators, $this->operators);
145 145
         $this->operatorsStrings = array_combine($this->operatorsStrings, $this->operatorsStrings);
146
-        $this->byPass= array_combine($this->byPass, $this->byPass);
146
+        $this->byPass = array_combine($this->byPass, $this->byPass);
147 147
     }
148 148
 
149 149
     /**
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function isOperand(Token $token)
156 156
     {
157
-        if(T_STRING == $token->getType()) {
158
-            return !(isset($this->byPass[$token->getValue()]) ||isset($this->operatorsStrings[$token->getValue()]));
157
+        if (T_STRING == $token->getType()) {
158
+            return !(isset($this->byPass[$token->getValue()]) || isset($this->operatorsStrings[$token->getValue()]));
159 159
         }
160 160
 
161 161
         return isset($this->operands[$token->getType()]);
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function isOperator(Token $token)
171 171
     {
172
-        if(T_STRING == $token->getType()) {
173
-            if(isset($this->byPass[$token->getValue()])) {
172
+        if (T_STRING == $token->getType()) {
173
+            if (isset($this->byPass[$token->getValue()])) {
174 174
                 return false;
175 175
             }
176 176
             return isset($this->operatorsStrings[$token->getValue()]);
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Component/McCabe/McCabe.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
         $tokens = $this->tokenizer->tokenize($filename);
57 57
 
58 58
         $ccn = 1; // default path
59
-        foreach($tokens as $token) {
59
+        foreach ($tokens as $token) {
60 60
 
61
-            switch($token->getType()) {
61
+            switch ($token->getType()) {
62 62
                 case T_IF:
63 63
                 case T_ELSEIF:
64 64
                 case T_FOREACH:
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     $ccn++;
78 78
                     break;
79 79
                 case T_STRING:
80
-                    if('?' == $token->getValue()) {
80
+                    if ('?' == $token->getValue()) {
81 81
                         $ccn = $ccn + 2;
82 82
                     }
83 83
                     break;
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Component/Myer/Myer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@
 block discarded – undo
63 63
             , T_BOOLEAN_OR => T_BOOLEAN_OR
64 64
         , T_LOGICAL_OR => T_LOGICAL_OR
65 65
         );
66
-        foreach($tokens as $token) {
67
-            if(isset($logicalOperators[$token->getType()])) {
66
+        foreach ($tokens as $token) {
67
+            if (isset($logicalOperators[$token->getType()])) {
68 68
                 $L++;
69 69
             }
70 70
         }
Please login to merge, or discard this patch.
Hal/Metrics/Complexity/Structural/CardAndAgresti/FileSystemComplexity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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))
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/CardAndAgresti/SystemComplexity.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/HenryAndKafura/Coupling.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/HenryAndKafura/FileCoupling.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,21 +54,21 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Structural/LCOM/FileLackOfCohesionOfMethods.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.