Passed
Push — master ( 120e65...4f9e14 )
by Ruben
01:52
created
src/Matrix.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,10 +24,14 @@  discard block
 block discarded – undo
24 24
     public static function submatrix($matrix, $columns)
25 25
     {
26 26
         $n = count($matrix);
27
-        if ($n == 0) return [];
27
+        if ($n == 0) {
28
+            return [];
29
+        }
28 30
        
29 31
         $m = count($matrix[0]);
30
-        if ($m == 0) return $matrix;
32
+        if ($m == 0) {
33
+            return $matrix;
34
+        }
31 35
        
32 36
         $result = [];       
33 37
         for ($i=0; $i<$n; $i++) {
@@ -47,7 +51,9 @@  discard block
 block discarded – undo
47 51
     public static function toSquareMatrix($matrix, $ncol, $mcol, $vcol, $sparse = False)
48 52
     {
49 53
         $n = count($matrix);
50
-        if ($n == 0) return [];
54
+        if ($n == 0) {
55
+            return [];
56
+        }
51 57
         
52 58
         $labels = [];
53 59
         $id = 0;
@@ -64,7 +70,9 @@  discard block
 block discarded – undo
64 70
             $val = $matrix[$i][$vcol];
65 71
             $data[] = [$nid, $mid, $val];
66 72
         }
67
-        if ($sparse) return ["data" => $data, "labels" => $labels];
73
+        if ($sparse) {
74
+            return ["data" => $data, "labels" => $labels];
75
+        }
68 76
         $nlab = count($labels);
69 77
         $result = [];
70 78
         for ($i=0; $i<$nlab; $i++) {           
@@ -84,7 +92,9 @@  discard block
 block discarded – undo
84 92
     {
85 93
         $result = [];
86 94
         $n = count($matrix1);        
87
-        if ($n != count($matrix2)) throw new \Exception("Summing non compatible matrices. ");
95
+        if ($n != count($matrix2)) {
96
+            throw new \Exception("Summing non compatible matrices. ");
97
+        }
88 98
         $m = count($matrix1[0]);
89 99
         for ($i=0;$i<$n;$i++) {
90 100
             $tmp = [];
@@ -107,7 +117,9 @@  discard block
 block discarded – undo
107 117
         $n2 = count($matrix2);        
108 118
         $m2 = count($matrix2[0]);
109 119
         
110
-        if ($n2 !== $m1) throw new \Exception("Incompatible matrices: matrix1.columns != matrix2.rows");
120
+        if ($n2 !== $m1) {
121
+            throw new \Exception("Incompatible matrices: matrix1.columns != matrix2.rows");
122
+        }
111 123
 
112 124
         $result = [];
113 125
         for ($i=0; $i<$n1; $i++) {           
@@ -154,9 +166,13 @@  discard block
 block discarded – undo
154 166
      */
155 167
     public static function power($matrix, $n)
156 168
     {
157
-        if($n <= 1) return $matrix;        
169
+        if($n <= 1) {
170
+            return $matrix;
171
+        }
158 172
         $resp = self::multiply($matrix, $matrix);
159
-        if($n == 2) return $resp;
173
+        if($n == 2) {
174
+            return $resp;
175
+        }
160 176
         for($i=2; $i<$n; $i++) {
161 177
             $resp = self::multiply($resp, $matrix);
162 178
         }
Please login to merge, or discard this patch.
src/Persistence.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,9 @@
 block discarded – undo
179 179
         $resp = [];
180 180
         foreach ($tests as $test) {
181 181
             $counts = self::getCountsById($pdo, $config, $test[0]);
182
-            if (count($counts) > 0) $resp[] = $counts;            
182
+            if (count($counts) > 0) {
183
+                $resp[] = $counts;
184
+            }
183 185
         }   
184 186
         return $resp;
185 187
     }
Please login to merge, or discard this patch.
src/SiteAnalyzer.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -179,8 +179,7 @@  discard block
 block discarded – undo
179 179
         
180 180
         if (array_key_exists("level", $options)) {
181 181
             $level = $options["level"];
182
-        }
183
-        else {
182
+        } else {
184 183
             $level = count($labels) - 1;
185 184
         }
186 185
         
@@ -212,8 +211,7 @@  discard block
 block discarded – undo
212 211
         
213 212
         if (array_key_exists("level", $options)) {
214 213
             $level = $options["level"];
215
-        }
216
-        else {
214
+        } else {
217 215
             $level = count($labels) - 1;
218 216
         }
219 217
         
Please login to merge, or discard this patch.
src/ML.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
         $niter = 0;
32 32
         $maxiter = 100;
33 33
         $npoints = count($data);
34
-        if ($npoints <= 0) throw new \Exception("Not enough data. ");    
34
+        if ($npoints <= 0) {
35
+            throw new \Exception("Not enough data. ");
36
+        }
35 37
         $ndimensions = count($data[0]);
36 38
         $centroids = [];
37 39
         for ($i=0;$i<$nclusters;$i++){
Please login to merge, or discard this patch.