Completed
Push — master ( e849b9...fa53d4 )
by Matthew
02:01
created
src/Command/DeleteAlertCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     ) {
195 195
         // Check each cols to make sure we handle SUM(BLAH) AS BLAH issues
196 196
 
197
-        foreach($cols as $key => $col) {
197
+        foreach ($cols as $key => $col) {
198 198
             if (strpos($col, 'AS ') !== false) {
199 199
                 $pos = strrpos($col, 'AS ') + 3; // Plus 3 for "AS "
200 200
                 $len = strlen($col);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $query->from($table);
211 211
         $query->where('resultID = ?', $id);
212 212
 
213
-        if (! empty($groupBy)) {
213
+        if (!empty($groupBy)) {
214 214
             $query->groupBy($groupBy);
215 215
         }
216 216
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
             $update->table($totalsTable);
227 227
             $update->where("{$filter} = ?", $row->$filter);
228 228
 
229
-            foreach($fields as $field) {
229
+            foreach ($fields as $field) {
230 230
                 $update->set($field, "{$field} - {$row->$field}");
231 231
             }
232 232
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
     protected function deleteAllFromTables(array $tables, $id, OutputInterface $output)
241 241
     {
242
-        foreach($tables as $table) {
242
+        foreach ($tables as $table) {
243 243
             $delete = $this->auraFactory->newDelete();
244 244
             $delete->from($table);
245 245
             $delete->where('resultID = ?', $id);
Please login to merge, or discard this patch.
src/Command/ArchiveCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
         $query->where('ResultStartTime < ?', $obj->format('U'));
62 62
         $query->where('Archived = 0');
63 63
 
64
-        if (! empty($input->getArgument('start'))) {
64
+        if (!empty($input->getArgument('start'))) {
65 65
             $query->where('ResultID >= ?', $input->getArgument('start'));
66 66
         }
67 67
 
68
-        if (! empty($input->getArgument('process'))) {
68
+        if (!empty($input->getArgument('process'))) {
69 69
             $query->where('ResultID <= ?', $input->getArgument('process'));
70 70
         }
71 71
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 'ws_xp'
91 91
             ];
92 92
 
93
-            for ($i=0; $i < $count; $i++) {
93
+            for ($i = 0; $i < $count; $i++) {
94 94
                 $this->archive($alerts[$i], $tables, $output);
95 95
 
96 96
                 $per = ($i / $count) * 100;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $this->guzzle->request(
112 112
             'POST',
113 113
             'https://hooks.slack.com/services/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',
114
-            ['json' => $payload ]
114
+            ['json' => $payload]
115 115
         );
116 116
 
117 117
         $output->writeln("Archived {$records} records!");
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $this->dbArchive->beginTransaction();
134 134
 
135 135
         // Get all data and insert it into the archive DB
136
-        foreach($tables as $table) {
136
+        foreach ($tables as $table) {
137 137
             $output->writeln("Alert #{$alert['ResultID']} - Table: {$table}");
138 138
 
139 139
             $sql = "SELECT * FROM {$table} WHERE resultID = :result";
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 }
156 156
 
157 157
                 $values = rtrim($values, ',');
158
-                $sql  = "INSERT INTO {$table} ({$cols}) VALUES {$values}";
158
+                $sql = "INSERT INTO {$table} ({$cols}) VALUES {$values}";
159 159
 
160 160
                 $this->dbArchive->exec($sql);
161 161
             }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         $this->db->beginTransaction();
176 176
 
177 177
         // Loop through all tables and delete the alert's data from the DB
178
-        foreach($tables as $table) {
178
+        foreach ($tables as $table) {
179 179
             $sql = "DELETE FROM {$table} WHERE resultID = :result";
180 180
             $stm = $this->db->prepare($sql);
181 181
             $stm->execute(['result' => $alert['ResultID']]);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public function buildCols($row)
208 208
     {
209 209
         $keys = [];
210
-        foreach($row as $key => $val) {
210
+        foreach ($row as $key => $val) {
211 211
             $keys[] = (string) $key;
212 212
         }
213 213
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     public function buildValues($row)
225 225
     {
226 226
         $values = [];
227
-        foreach($row as $key => $val) {
227
+        foreach ($row as $key => $val) {
228 228
             $val = str_replace("'", '', $val); // Remove any apostophies from char names
229 229
             $values[] = $val;
230 230
         }
Please login to merge, or discard this patch.
src/Controller/Endpoint/Data/DataEndpointController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         }
80 80
 
81 81
         // Now return the character the outfit injected
82
-        if (! empty($character['data']['outfit'])) {
82
+        if (!empty($character['data']['outfit'])) {
83 83
             try {
84 84
                 $outfit = $this->getOutfit($character['data']['outfit']);
85 85
             } catch (CensusErrorException $e) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         // First, check if we have the character in Redis
139 139
         $redisCheck = $this->checkRedis('cache', 'character', $id);
140 140
 
141
-        if (! empty($redisCheck)) {
141
+        if (!empty($redisCheck)) {
142 142
             return $redisCheck;
143 143
         }
144 144
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         // First, check if we have the outfit in Redis
188 188
         $redisCheck = $this->checkRedis('cache', 'outfit', $id);
189 189
 
190
-        if (! empty($redisCheck)) {
190
+        if (!empty($redisCheck)) {
191 191
             return $redisCheck;
192 192
         }
193 193
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         ];
245 245
 
246 246
         // Loop through each environment and get the first result
247
-        foreach($environments as $env) {
247
+        foreach ($environments as $env) {
248 248
             $url = "https://census.daybreakgames.com/s:{$config['census_service_id']}/get/{$env}/{$endpoint}";
249 249
 
250 250
             $req  = $guzzle->request('GET', $url);
Please login to merge, or discard this patch.
Controller/Endpoint/Leaderboards/LeaderboardLadderEndpointController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
 
84 84
         $data = [];
85 85
 
86
-        foreach($config['servers'] as $server) {
86
+        foreach ($config['servers'] as $server) {
87 87
             $key = "ps2alerts:api:leaderboards:status:{$server}";
88 88
 
89 89
             if ($redis->exists($key)) {
Please login to merge, or discard this patch.
src/Controller/Endpoint/Leaderboards/LeaderboardEndpointController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             }
84 84
         }
85 85
 
86
-        if (! isset($field)) {
86
+        if (!isset($field)) {
87 87
             return $this->errorWrongArgs('Field wasn\'t provided and is required.');
88 88
         }
89 89
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         // Gets outfit details
114 114
         for ($i = 0; $i < $count; $i++) {
115
-            if (! empty($players[$i]['playerOutfit'])) {
115
+            if (!empty($players[$i]['playerOutfit'])) {
116 116
                 // Gets outfit details
117 117
                 try {
118 118
                     $outfit = $this->dataEndpoint->getOutfit($players[$i]['playerOutfit']);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             }
177 177
         }
178 178
 
179
-        if (! isset($field)) {
179
+        if (!isset($field)) {
180 180
             return $this->errorWrongArgs('Field wasn\'t provided and is required.');
181 181
         }
182 182
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             }
240 240
         }
241 241
 
242
-        if (! isset($field)) {
242
+        if (!isset($field)) {
243 243
             return $this->errorWrongArgs('Field wasn\'t provided and is required.');
244 244
         }
245 245
 
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
     public function validateRequestVars($request)
283 283
     {
284 284
         try {
285
-            if (! empty($_GET['field'])) {
285
+            if (!empty($_GET['field'])) {
286 286
                 $this->parseField($_GET['field']);
287 287
             }
288 288
 
289
-            if (! empty($_GET['server'])) {
289
+            if (!empty($_GET['server'])) {
290 290
                 $this->parseServer($_GET['server']);
291 291
             }
292 292
 
293
-            if (! empty($_GET['limit'])) {
293
+            if (!empty($_GET['limit'])) {
294 294
                 $this->parseOffset($_GET['limit']);
295 295
             }
296 296
 
297
-            if (! empty($_GET['offset'])) {
297
+            if (!empty($_GET['offset'])) {
298 298
                 $this->parseOffset($_GET['offset']);
299 299
             }
300 300
         } catch (InvalidArgumentException $e) {
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             'captures'
321 321
         ];
322 322
 
323
-        if (! empty($field) && in_array($field, $validFields)) {
323
+        if (!empty($field) && in_array($field, $validFields)) {
324 324
             return $field;
325 325
         }
326 326
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             unset($validServers[$key]);
342 342
         }
343 343
 
344
-        if (! empty($server) && in_array($server, $validServers)) {
344
+        if (!empty($server) && in_array($server, $validServers)) {
345 345
             return $server;
346 346
         }
347 347
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public function parseLimit($limit)
357 357
     {
358
-        if (! isset($limit) && ! is_numeric($limit)) {
358
+        if (!isset($limit) && !is_numeric($limit)) {
359 359
             throw new InvalidArgumentException("Limit needs to be in numerical format.");
360 360
         }
361 361
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function parseOffset($offset)
369 369
     {
370
-        if (! isset($offset) && ! is_numeric($offset)) {
370
+        if (!isset($offset) && !is_numeric($offset)) {
371 371
             throw new InvalidArgumentException("Offset needs to be in numerical format.");
372 372
         }
373 373
 
Please login to merge, or discard this patch.
src/Controller/Endpoint/ContextualDataEndpointController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,6 +22,6 @@
 block discarded – undo
22 22
     public function __construct(
23 23
         Manager          $fractal
24 24
     ) {
25
-        $this->fractal     = $fractal;
25
+        $this->fractal = $fractal;
26 26
     }
27 27
 }
Please login to merge, or discard this patch.
src/Controller/Endpoint/Search/SearchEndpointController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         if ($this->parsePlayerName($args['term'], $response)) {
53 53
             $players = $this->searchForPlayer($args['term']);
54 54
 
55
-            if (! empty($players)) {
55
+            if (!empty($players)) {
56 56
                 return $this->respond(
57 57
                     'collection',
58 58
                     $players,
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         if ($this->parseOutfitName($name, $response)) {
82 82
             $outfits = $this->searchForOutfit($name);
83 83
 
84
-            if (! empty($outfits)) {
84
+            if (!empty($outfits)) {
85 85
                 return $this->respond(
86 86
                     'collection',
87 87
                     $outfits,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             return $this->errorWrongArgs('Player ID cannot be longer than 19 characters.');
200 200
         }
201 201
 
202
-        if (! is_numeric($id)) {
202
+        if (!is_numeric($id)) {
203 203
             return $this->errorWrongArgs('Player ID must be numeric.');
204 204
         }
205 205
 
Please login to merge, or discard this patch.
src/Controller/Endpoint/AbstractEndpointController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
      */
329 329
     public function getIncludesFromRequest()
330 330
     {
331
-        if (! empty($_GET['embed'])) {
331
+        if (!empty($_GET['embed'])) {
332 332
             $this->fractal->parseIncludes($_GET['embed']);
333 333
         }
334 334
     }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             throw new \Exception();
409 409
         }
410 410
 
411
-        if (! $time) {
411
+        if (!$time) {
412 412
             $time = 3600 * 24; // 1 day
413 413
         }
414 414
 
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
         $numericals = ['servers', 'zones'];
433 433
         $strings = ['factions', 'brackets'];
434 434
 
435
-        if (! empty($queryString)) {
435
+        if (!empty($queryString)) {
436 436
             $check = explode(',', $queryString);
437 437
 
438 438
             // Run a check on the IDs provided to make sure they're valid and no naughty things are being passed
439 439
             foreach ($check as $id) {
440 440
                 // If the query string should contain only numbers
441 441
                 if (in_array($mode, $numericals)) {
442
-                    if (! is_numeric($id)) {
442
+                    if (!is_numeric($id)) {
443 443
                         throw new InvalidArgumentException("Non numerical ID detected. Only numerical IDs are accepted with this request.");
444 444
                     }
445 445
                 }
@@ -449,14 +449,14 @@  discard block
 block discarded – undo
449 449
                     }
450 450
                 }
451 451
 
452
-                if (! in_array($id, $filters)) {
452
+                if (!in_array($id, $filters)) {
453 453
                     throw new InvalidArgumentException("Unrecognized {$mode}. Please check the IDs you sent.");
454 454
                 }
455 455
             }
456 456
 
457 457
             // Format into strings comma seperated for SQL
458 458
             if (in_array($mode, $strings)) {
459
-                $queryString = "'" . implode("','", $check) . "'";
459
+                $queryString = "'".implode("','", $check)."'";
460 460
             }
461 461
 
462 462
             return $queryString;
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $return = implode(',', $filters);
466 466
 
467 467
         if (in_array($mode, $strings)) {
468
-            $return = "'" . implode("','", $filters) . "'";
468
+            $return = "'".implode("','", $filters)."'";
469 469
         }
470 470
 
471 471
         // If no string was provided, returns all data encoded as a comma seperated string
Please login to merge, or discard this patch.
src/Controller/Endpoint/Alerts/AlertCombatEndpointController.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,23 +49,23 @@  discard block
 block discarded – undo
49 49
             $data = $this->checkRedis('api', 'combatTotals', "{$server}-data");
50 50
             $dataArchive = $this->checkRedis('api', 'combatTotals', "{$server}-dataArchive");
51 51
 
52
-            if (! $data || ! $dataArchive) {
52
+            if (!$data || !$dataArchive) {
53 53
                 $sums = [];
54 54
                 foreach ($metrics as $metric) {
55 55
                     foreach ($factions as $faction) {
56
-                        $dbMetric = $metric . strtoupper($faction); // e.g. killsVS
57
-                        $dataMetric = $metric . strtoupper($faction); // e.g. killsVS
56
+                        $dbMetric = $metric.strtoupper($faction); // e.g. killsVS
57
+                        $dataMetric = $metric.strtoupper($faction); // e.g. killsVS
58 58
 
59 59
                         // Handle teamkills inconsistency
60 60
                         if ($metric === 'teamkills') {
61
-                            $dbMetric = 'teamKills' . strtoupper($faction);
61
+                            $dbMetric = 'teamKills'.strtoupper($faction);
62 62
                         }
63 63
                         $sums[] = "SUM(factions.{$dbMetric}) AS $dataMetric";
64 64
                     }
65 65
 
66 66
                     // Totals
67
-                    $dbMetric = 'total' . ucfirst($metric); // e.g. killsVS
68
-                    $dataMetric = 'total' . ucfirst($metric); // e.g. killsVS
67
+                    $dbMetric = 'total'.ucfirst($metric); // e.g. killsVS
68
+                    $dataMetric = 'total'.ucfirst($metric); // e.g. killsVS
69 69
 
70 70
                     // Handle teamkills inconsistency
71 71
                     if ($metric === 'teamkills') {
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
             // Merge the two arrays together
101 101
             foreach ($metrics as $metric) {
102 102
                 // Tot up totals
103
-                $dbMetric = 'total' . ucfirst($metric);
103
+                $dbMetric = 'total'.ucfirst($metric);
104 104
                 $mergedArray['totals'][$metric] = (int) $data[$dbMetric] + (int) $dataArchive[$dbMetric];
105 105
                 $results['all']['totals'][$metric] += $mergedArray['totals'][$metric];
106 106
 
107 107
                 foreach ($factions as $faction) {
108
-                    $dbMetric = $metric . strtoupper($faction);
108
+                    $dbMetric = $metric.strtoupper($faction);
109 109
                     $mergedArray[$metric][$faction] = (int) $data[$dbMetric] + (int) $dataArchive[$dbMetric];
110 110
                     $results['all'][$metric][$faction] += $mergedArray[$metric][$faction];
111 111
                 }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             $dataArchive = $this->checkRedis('api', 'classCombat', "{$server}-dataArchive", 'object');
149 149
 
150 150
             // If data needs a pull
151
-            if (! $data || ! $dataArchive) {
151
+            if (!$data || !$dataArchive) {
152 152
                 $query = $this->combatRepository->newQuery('single', true);
153 153
                 $query->cols([
154 154
                         'classID',
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
             // Typecase into ints and increase totals
182 182
             $metrics = ['kills', 'deaths', 'teamkills', 'suicides'];
183 183
             foreach ($data as $row) {
184
-                $row->classID   = (int) $row->classID;
185
-                $row->server   = (int) $row->server;
184
+                $row->classID = (int) $row->classID;
185
+                $row->server = (int) $row->server;
186 186
                 $classGroup = $this->findClassGrouping($row->classID);
187 187
                 $faction = $this->findClassFaction($row->classID);
188 188
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
             }
202 202
 
203 203
             foreach ($dataArchive as $row) {
204
-                $row->classID   = (int) $row->classID;
205
-                $row->server   = (int) $row->server;
204
+                $row->classID = (int) $row->classID;
205
+                $row->server = (int) $row->server;
206 206
 
207 207
                 foreach ($metrics as $metric) {
208 208
                     $row->$metric = (int) $row->$metric;
Please login to merge, or discard this patch.