Completed
Push — master ( 22d5e0...32e5c2 )
by MusikAnimal
02:33
created
src/Xtools/EditCounter.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
             $promises[] = $promise;
118 118
 
119 119
             // Handle response of $promise asynchronously.
120
-            $promise->then(function ($response) use ($key, $endpoint) {
121
-                $result = (array) json_decode($response->getBody()->getContents());
120
+            $promise->then(function($response) use ($key, $endpoint) {
121
+                $result = (array)json_decode($response->getBody()->getContents());
122 122
 
123 123
                 $this->getRepository()
124 124
                     ->getLog()
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                     // We'll log this to see how often it happens.
136 136
                     $this->getRepository()
137 137
                         ->getLog()
138
-                        ->error("Failed to fetch data for $endpoint via async, " .
138
+                        ->error("Failed to fetch data for $endpoint via async, ".
139 139
                             "re-attempting synchoronously.");
140 140
                 }
141 141
             });
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
         // Filter out unblocks unless requested.
193 193
         if ($blocksOnly) {
194
-            $blocks = array_filter($blocks, function ($block) {
194
+            $blocks = array_filter($blocks, function($block) {
195 195
                 return $block['log_action'] === 'block';
196 196
             });
197 197
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function countAllRevisions()
227 227
     {
228
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
228
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
229 229
     }
230 230
 
231 231
     /**
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function countRevisionsWithoutComments()
246 246
     {
247
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
247
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
248 248
     }
249 249
 
250 250
     /**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function countAllPagesEdited()
285 285
     {
286
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
286
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
287 287
     }
288 288
 
289 289
     /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function countPagesCreated()
295 295
     {
296
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
296
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
297 297
     }
298 298
 
299 299
     /**
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             } elseif ($block['log_action'] === 'unblock') {
434 434
                 // The last block was lifted. So the duration will be the time from when the
435 435
                 // last block was set to the time of the unblock.
436
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
436
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
437 437
                 if ($timeSinceLastBlock > $this->longestBlockSeconds) {
438 438
                     $this->longestBlockSeconds = $timeSinceLastBlock;
439 439
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
                 // The last block was modified. So we will adjust $lastBlock to include
445 445
                 // the difference of the duration of the new reblock, and time since the last block.
446 446
                 // $lastBlock is left unchanged if its duration was indefinite.
447
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
448
-                $lastBlock[1] = $timeSinceLastBlock + $duration;
447
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
448
+                $lastBlock[1] = $timeSinceLastBlock+$duration;
449 449
             }
450 450
         }
451 451
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
         }
456 456
 
457 457
         // Test if the last block is still active, and if so use the expiry as the duration.
458
-        $lastBlockExpiry = $lastBlock[0] + $lastBlock[1];
458
+        $lastBlockExpiry = $lastBlock[0]+$lastBlock[1];
459 459
         if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) {
460 460
             $this->longestBlockSeconds = $lastBlock[1];
461 461
         // Otherwise, test if the duration of the last block is now the longest overall.
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         // If invalid, $duration is left as null.
497 497
         if (strtotime($durationStr)) {
498 498
             $expiry = strtotime($durationStr, $timestamp);
499
-            $duration = $expiry - $timestamp;
499
+            $duration = $expiry-$timestamp;
500 500
         }
501 501
 
502 502
         return [$timestamp, $duration];
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
574 574
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
575 575
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
576
-        return $import + $interwiki + $upload;
576
+        return $import+$interwiki+$upload;
577 577
     }
578 578
 
579 579
     /**
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
     public function approvals()
698 698
     {
699 699
         $logCounts = $this->getLogCounts();
700
-        $total = $logCounts['review-approve'] +
701
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
702
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
700
+        $total = $logCounts['review-approve']+
701
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
702
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
703 703
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
704 704
         return $total;
705 705
     }
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
         $logCounts = $this->getLogCounts();
724 724
         $create2 = $logCounts['newusers-create2'] ?: 0;
725 725
         $byemail = $logCounts['newusers-byemail'] ?: 0;
726
-        return $create2 + $byemail;
726
+        return $create2+$byemail;
727 727
     }
728 728
 
729 729
     /**
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
777 777
         $out = [
778
-            'yearLabels' => [],  // labels for years
778
+            'yearLabels' => [], // labels for years
779 779
             'monthLabels' => [], // labels for months
780 780
             'totals' => [], // actual totals, grouped by namespace, year and then month
781 781
         ];
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                 $out['totals'][$ns][$total['year']] = [];
804 804
             }
805 805
 
806
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
806
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
807 807
         }
808 808
 
809 809
         $dateRange = new DatePeriod(
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
         );
814 814
 
815 815
         foreach ($dateRange as $monthObj) {
816
-            $year = (int) $monthObj->format('Y');
817
-            $month = (int) $monthObj->format('n');
816
+            $year = (int)$monthObj->format('Y');
817
+            $month = (int)$monthObj->format('n');
818 818
 
819 819
             // Fill in labels
820 820
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 
931 931
         if ($sorted) {
932 932
             // Sort.
933
-            uasort($this->globalEditCounts, function ($a, $b) {
934
-                return $b['total'] - $a['total'];
933
+            uasort($this->globalEditCounts, function($a, $b) {
934
+                return $b['total']-$a['total'];
935 935
             });
936 936
         }
937 937
 
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
968 968
             }
969 969
             $page = $project->getRepository()
970
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
970
+                ->getPage($project, $nsName.':'.$revision['page_title']);
971 971
             $edit = new Edit($page, $revision);
972 972
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
973 973
         }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
     public function countSmallEdits()
1009 1009
     {
1010 1010
         $editSizeData = $this->getEditSizeData();
1011
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
1011
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
1012 1012
     }
1013 1013
 
1014 1014
     /**
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
     public function countLargeEdits()
1019 1019
     {
1020 1020
         $editSizeData = $this->getEditSizeData();
1021
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
1021
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
1022 1022
     }
1023 1023
 
1024 1024
     /**
Please login to merge, or discard this patch.