Passed
Push — master ( ed30c1...df214b )
by Ruben
02:19
created
src/SiteAnalyzer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public static function getPDO($config, $options)
84 84
     {
85
-        if (array_key_exists("pdo",$options)) {
85
+        if (array_key_exists("pdo", $options)) {
86 86
             return $options["pdo"];
87 87
         }         
88 88
         return  Persistence::getPDO($config);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         }
186 186
         
187 187
         $result = $data;
188
-        for ($i=1;$i<$level;$i++) {
188
+        for ($i = 1; $i < $level; $i++) {
189 189
             $tmp = Matrix::multiply($result, $data);
190 190
             $result = Matrix::sum($result, $tmp);
191 191
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         }
219 219
         
220 220
         $result = $data;
221
-        for ($i=1;$i<$level;$i++) {
221
+        for ($i = 1; $i < $level; $i++) {
222 222
             $tmp = Matrix::multiply($result, $data);
223 223
             $result = Matrix::sum($result, $tmp);
224 224
         }
Please login to merge, or discard this patch.
src/ML.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                 $bdist = INF;
45 45
                 for ($i = 0; $i < $nclusters; $i++) {
46 46
                     $ndist = self::eclideanDistance($data[$j], $centroids[$i]);
47
-                    if($bdist > $ndist) {
47
+                    if ($bdist > $ndist) {
48 48
                         $bdist = $ndist;
49 49
                         $best = $i;
50 50
                     }            
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             // Check change 
57 57
             $finished = true;
58 58
             if (count($resp) > 0) {
59
-                for ($j=0; $j < $npoints; $j++) {        
59
+                for ($j = 0; $j < $npoints; $j++) {        
60 60
                     if ($resp[$j]!==$nresp[$j]) {
61 61
                         $finished = false;
62 62
                         break;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             }
68 68
             $resp = $nresp;
69 69
             // Recalculate the centroids
70
-            $centroids = self::initCentroids($nclusters, $ndimensions, function(){return 0;});
70
+            $centroids = self::initCentroids($nclusters, $ndimensions, function() {return 0; });
71 71
             $counts = array_fill(0, $nclusters, 0);
72 72
             for ($j = 0; $j < $npoints; $j++) {    
73 73
                 $centroids[$resp[$j]] = Matrix::sumArray($centroids[$resp[$j]], $data[$j]);
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $resp = [];
88 88
         foreach ($data as $row) {
89
-            if ( !self::contains_point($resp, $row) ) {
89
+            if (!self::contains_point($resp, $row)) {
90 90
                 $resp[] = $row;
91 91
             }
92
-            if (count($resp) == $n) {
92
+            if (count($resp)==$n) {
93 93
                 return $resp;
94 94
             }
95 95
         }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     private static function contains_point($matrix, $array) 
103 103
     {
104
-        foreach ($matrix as $row){
104
+        foreach ($matrix as $row) {
105 105
             if (self::isEqual($row, $array)) return true;
106 106
         }
107 107
         return false;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
     private static function isEqual($array1, $array2)
114 114
     {
115 115
         $len = count($array1);
116
-        if($len != count($array2) ) return false;
117
-        for ($i=0; $i<$len; $i++) {
118
-            if ($array1[$i] != $array2[$i]) return false;
116
+        if ($len!=count($array2)) return false;
117
+        for ($i = 0; $i < $len; $i++) {
118
+            if ($array1[$i]!=$array2[$i]) return false;
119 119
         }
120 120
         return true;
121 121
     }
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
         $resp = [];
129 129
         $n = count($centroids);
130 130
         $d = count($centroids[0]);
131
-        for ($i=0;$i<$n;$i++) {
131
+        for ($i = 0; $i < $n; $i++) {
132 132
             $tmp = [];
133
-            for ($j=0;$j<$d;$j++){
134
-                $tmp[] = $centroids[$i][$j]/$counts[$i];
133
+            for ($j = 0; $j < $d; $j++) {
134
+                $tmp[] = $centroids[$i][$j] / $counts[$i];
135 135
             }
136 136
             $resp[] = $tmp;
137 137
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     public static function eclideanDistance($p1, $p2) {
161 161
        $len = count($p1);
162 162
        $acum = 0;
163
-       for($i=0; $i<$len; $i++) {
163
+       for ($i = 0; $i < $len; $i++) {
164 164
            $acum += ($p1[$i] - $p2[$i])**2;
165 165
        }
166 166
        return sqrt($acum);
Please login to merge, or discard this patch.