Passed
Push — master ( 782005...8964b9 )
by MusikAnimal
06:51
created
src/Xtools/EditCounter.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
             $promises[] = $promise;
141 141
 
142 142
             // Handle response of $promise asynchronously.
143
-            $promise->then(function ($response) use ($key, $endpoint) {
144
-                $result = (array) json_decode($response->getBody()->getContents());
143
+            $promise->then(function($response) use ($key, $endpoint) {
144
+                $result = (array)json_decode($response->getBody()->getContents());
145 145
 
146 146
                 $this->getRepository()
147 147
                     ->getLog()
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                     // We'll log this to see how often it happens.
159 159
                     $this->getRepository()
160 160
                         ->getLog()
161
-                        ->error("Failed to fetch data for $endpoint via async, " .
161
+                        ->error("Failed to fetch data for $endpoint via async, ".
162 162
                             "re-attempting synchoronously.");
163 163
                 }
164 164
             });
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
         // Filter out unblocks unless requested.
216 216
         if ($blocksOnly) {
217
-            $blocks = array_filter($blocks, function ($block) {
217
+            $blocks = array_filter($blocks, function($block) {
218 218
                 return $block['log_action'] === 'block';
219 219
             });
220 220
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public function countAllRevisions()
388 388
     {
389
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
389
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
390 390
     }
391 391
 
392 392
     /**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public function countRevisionsWithoutComments()
407 407
     {
408
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
408
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
409 409
     }
410 410
 
411 411
     /**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
      */
445 445
     public function countAllPagesEdited()
446 446
     {
447
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
447
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
448 448
     }
449 449
 
450 450
     /**
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
      */
455 455
     public function countPagesCreated()
456 456
     {
457
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
457
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
458 458
     }
459 459
 
460 460
     /**
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
             } elseif ($block['log_action'] === 'unblock') {
595 595
                 // The last block was lifted. So the duration will be the time from when the
596 596
                 // last block was set to the time of the unblock.
597
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
597
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
598 598
                 if ($timeSinceLastBlock > $this->longestBlockSeconds) {
599 599
                     $this->longestBlockSeconds = $timeSinceLastBlock;
600 600
 
@@ -605,8 +605,8 @@  discard block
 block discarded – undo
605 605
                 // The last block was modified. So we will adjust $lastBlock to include
606 606
                 // the difference of the duration of the new reblock, and time since the last block.
607 607
                 // $lastBlock is left unchanged if its duration was indefinite.
608
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
609
-                $lastBlock[1] = $timeSinceLastBlock + $duration;
608
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
609
+                $lastBlock[1] = $timeSinceLastBlock+$duration;
610 610
             }
611 611
         }
612 612
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         }
617 617
 
618 618
         // Test if the last block is still active, and if so use the expiry as the duration.
619
-        $lastBlockExpiry = $lastBlock[0] + $lastBlock[1];
619
+        $lastBlockExpiry = $lastBlock[0]+$lastBlock[1];
620 620
         if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) {
621 621
             $this->longestBlockSeconds = $lastBlock[1];
622 622
         // Otherwise, test if the duration of the last block is now the longest overall.
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
         // If invalid, $duration is left as null.
658 658
         if (strtotime($durationStr)) {
659 659
             $expiry = strtotime($durationStr, $timestamp);
660
-            $duration = $expiry - $timestamp;
660
+            $duration = $expiry-$timestamp;
661 661
         }
662 662
 
663 663
         return [$timestamp, $duration];
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
735 735
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
736 736
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
737
-        return $import + $interwiki + $upload;
737
+        return $import+$interwiki+$upload;
738 738
     }
739 739
 
740 740
     /**
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
     public function approvals()
862 862
     {
863 863
         $logCounts = $this->getLogCounts();
864
-        $total = $logCounts['review-approve'] +
865
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
866
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
864
+        $total = $logCounts['review-approve']+
865
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
866
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
867 867
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
868 868
         return $total;
869 869
     }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
         $logCounts = $this->getLogCounts();
888 888
         $create2 = $logCounts['newusers-create2'] ?: 0;
889 889
         $byemail = $logCounts['newusers-byemail'] ?: 0;
890
-        return $create2 + $byemail;
890
+        return $create2+$byemail;
891 891
     }
892 892
 
893 893
     /**
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 
971 971
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
972 972
         $out = [
973
-            'yearLabels' => [],  // labels for years
973
+            'yearLabels' => [], // labels for years
974 974
             'monthLabels' => [], // labels for months
975 975
             'totals' => [], // actual totals, grouped by namespace, year and then month
976 976
         ];
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
                 $out['totals'][$ns][$total['year']] = [];
1038 1038
             }
1039 1039
 
1040
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
1040
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
1041 1041
         }
1042 1042
 
1043 1043
         return [$out, $firstEdit];
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
     private function fillInMonthTotalsAndLabels($out, DatePeriod $dateRange)
1055 1055
     {
1056 1056
         foreach ($dateRange as $monthObj) {
1057
-            $year = (int) $monthObj->format('Y');
1057
+            $year = (int)$monthObj->format('Y');
1058 1058
             $yearLabel = $this->i18n->dateFormat($monthObj, 'yyyy');
1059
-            $month = (int) $monthObj->format('n');
1059
+            $month = (int)$monthObj->format('n');
1060 1060
             $monthLabel = $this->i18n->dateFormat($monthObj, 'yyyy-MM');
1061 1061
 
1062 1062
             // Fill in labels
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
         if ($sorted) {
1207 1207
             // Sort.
1208
-            uasort($this->globalEditCounts, function ($a, $b) {
1209
-                return $b['total'] - $a['total'];
1208
+            uasort($this->globalEditCounts, function($a, $b) {
1209
+                return $b['total']-$a['total'];
1210 1210
             });
1211 1211
         }
1212 1212
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
1251 1251
             }
1252 1252
             $page = $project->getRepository()
1253
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
1253
+                ->getPage($project, $nsName.':'.$revision['page_title']);
1254 1254
             $edit = new Edit($page, $revision);
1255 1255
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
1256 1256
         }
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
     public function countSmallEdits()
1293 1293
     {
1294 1294
         $editSizeData = $this->getEditSizeData();
1295
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
1295
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
1296 1296
     }
1297 1297
 
1298 1298
     /**
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
     public function countLargeEdits()
1303 1303
     {
1304 1304
         $editSizeData = $this->getEditSizeData();
1305
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
1305
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
1306 1306
     }
1307 1307
 
1308 1308
     /**
Please login to merge, or discard this patch.