Completed
Pull Request — master (#66)
by MusikAnimal
02:49
created
src/Xtools/EditCounter.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     protected function getPairData()
80 80
     {
81
-        if (! is_array($this->pairData)) {
81
+        if (!is_array($this->pairData)) {
82 82
             $this->pairData = $this->getRepository()
83 83
                 ->getPairData($this->project, $this->user);
84 84
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getLogCounts()
93 93
     {
94
-        if (! is_array($this->logCounts)) {
94
+        if (!is_array($this->logCounts)) {
95 95
             $this->logCounts = $this->getRepository()
96 96
                 ->getLogCounts($this->project, $this->user);
97 97
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function countAllRevisions()
142 142
     {
143
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
143
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
144 144
     }
145 145
 
146 146
     /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function countRevisionsWithoutComments()
161 161
     {
162
-        return $this->countAllRevisions() - $this->countRevisionsWithComments();
162
+        return $this->countAllRevisions()-$this->countRevisionsWithComments();
163 163
     }
164 164
 
165 165
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function countAllPagesEdited()
200 200
     {
201
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
201
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
202 202
     }
203 203
 
204 204
     /**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function countPagesCreated()
210 210
     {
211
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
211
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
212 212
     }
213 213
 
214 214
     /**
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             // Try block just in case there are older, unpredictable formats
337 337
             try {
338 338
                 $expiry = strtotime($durationStr, $timestamp);
339
-                $duration = ($expiry - $timestamp) / (60 * 60 * 24);
339
+                $duration = ($expiry-$timestamp) / (60 * 60 * 24);
340 340
 
341 341
                 if (!$duration || $duration > $this->longestBlockDays) {
342 342
                     $this->longestBlockDays = $duration;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
421 421
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
422 422
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
423
-        return $import + $interwiki + $upload;
423
+        return $import+$interwiki+$upload;
424 424
     }
425 425
 
426 426
     /**
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
     public function approvals()
545 545
     {
546 546
         $logCounts = $this->getLogCounts();
547
-        $total = $logCounts['review-approve'] +
548
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
549
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
547
+        $total = $logCounts['review-approve']+
548
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
549
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
550 550
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
551 551
         return $total;
552 552
     }
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
         $logCounts = $this->getLogCounts();
571 571
         $create2 = $logCounts['newusers-create2'] ?: 0;
572 572
         $byemail = $logCounts['newusers-byemail'] ?: 0;
573
-        return $create2 + $byemail;
573
+        return $create2+$byemail;
574 574
     }
575 575
 
576 576
     /**
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 
614 614
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
615 615
         $out = [
616
-            'yearLabels' => [],  // labels for years
616
+            'yearLabels' => [], // labels for years
617 617
             'monthLabels' => [], // labels for months
618 618
             'totals' => [], // actual totals, grouped by namespace, year and then month
619 619
         ];
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
         $registrationDate = $this->user->getRegistrationDate($this->project);
623 623
         // If not empty, we know the first month/year to show.
624 624
         if (!empty($registrationDate)) {
625
-            $minYear = (int) $registrationDate->format('Y');
625
+            $minYear = (int)$registrationDate->format('Y');
626 626
             $minMonth = $registrationDate->format('m');
627 627
         } else {
628
-            $minYear = (int) $currentTime->format('Y');
628
+            $minYear = (int)$currentTime->format('Y');
629 629
 
630 630
             // For users without a registration date, we'll just
631 631
             //   use January as the first month.
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         foreach ($totals as $total) {
638 638
             // Figure out the first year they made an edit if we don't have a registration date.
639 639
             if (empty($registrationDate)) {
640
-                $minYear = (int) min($minYear, $total['year']);
640
+                $minYear = (int)min($minYear, $total['year']);
641 641
             }
642 642
 
643 643
             // Collate the counts by namespace, and then year and month.
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
                 $out['totals'][$ns][$total['year']] = [];
652 652
             }
653 653
 
654
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
654
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
655 655
         }
656 656
 
657 657
         $dateRange = new DatePeriod(
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
         );
662 662
 
663 663
         foreach ($dateRange as $monthObj) {
664
-            $year = (int) $monthObj->format('Y');
665
-            $month = (int) $monthObj->format('n');
664
+            $year = (int)$monthObj->format('Y');
665
+            $month = (int)$monthObj->format('n');
666 666
 
667 667
             // Fill in labels
668 668
             $out['monthLabels'][] = $monthObj->format('Y/m');
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
                 ->globalEditCounts($this->user, $this->project);
772 772
             if ($sorted) {
773 773
                 // Sort.
774
-                uasort($this->globalEditCounts, function ($a, $b) {
775
-                    return $b['total'] - $a['total'];
774
+                uasort($this->globalEditCounts, function($a, $b) {
775
+                    return $b['total']-$a['total'];
776 776
                 });
777 777
             }
778 778
         }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
811 811
             }
812 812
             $page = $project->getRepository()
813
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
813
+                ->getPage($project, $nsName.':'.$revision['page_title']);
814 814
             $edit = new Edit($page, $revision);
815 815
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
816 816
         }
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
      */
828 828
     protected function getEditSizeData()
829 829
     {
830
-        if (! is_array($this->editSizeData)) {
830
+        if (!is_array($this->editSizeData)) {
831 831
             $this->editSizeData = $this->getRepository()
832 832
                 ->getEditSizeData($this->project, $this->user);
833 833
         }
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     public function countSmallEdits()
852 852
     {
853 853
         $editSizeData = $this->getEditSizeData();
854
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
854
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
855 855
     }
856 856
 
857 857
     /**
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
     public function countLargeEdits()
862 862
     {
863 863
         $editSizeData = $this->getEditSizeData();
864
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
864
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
865 865
     }
866 866
 
867 867
     /**
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
     /**
475 475
      * Get the date and time of the user's first edit.
476
-     * @return DateTime|bool The time of the first revision, or false.
476
+     * @return DateInterval The time of the first revision, or false.
477 477
      */
478 478
     public function datetimeFirstRevision()
479 479
     {
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
     /**
485 485
      * Get the date and time of the user's first edit.
486
-     * @return DateTime|bool The time of the last revision, or false.
486
+     * @return DateInterval The time of the last revision, or false.
487 487
      */
488 488
     public function datetimeLastRevision()
489 489
     {
Please login to merge, or discard this patch.