@@ -6,7 +6,6 @@ |
||
| 6 | 6 | namespace Xtools; |
| 7 | 7 | |
| 8 | 8 | use DateTime; |
| 9 | -use Exception; |
|
| 10 | 9 | use DatePeriod; |
| 11 | 10 | use DateInterval; |
| 12 | 11 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected function getPairData() |
| 84 | 84 | { |
| 85 | - if (! is_array($this->pairData)) { |
|
| 85 | + if (!is_array($this->pairData)) { |
|
| 86 | 86 | $this->pairData = $this->getRepository() |
| 87 | 87 | ->getPairData($this->project, $this->user); |
| 88 | 88 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function getLogCounts() |
| 97 | 97 | { |
| 98 | - if (! is_array($this->logCounts)) { |
|
| 98 | + if (!is_array($this->logCounts)) { |
|
| 99 | 99 | $this->logCounts = $this->getRepository() |
| 100 | 100 | ->getLogCounts($this->project, $this->user); |
| 101 | 101 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // Filter out unblocks unless requested. |
| 121 | 121 | if ($blocksOnly) { |
| 122 | - $blocks = array_filter($blocks, function ($block) { |
|
| 122 | + $blocks = array_filter($blocks, function($block) { |
|
| 123 | 123 | return $block['log_action'] === 'block'; |
| 124 | 124 | }); |
| 125 | 125 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function countAllRevisions() |
| 155 | 155 | { |
| 156 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
| 156 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function countRevisionsWithoutComments() |
| 174 | 174 | { |
| 175 | - return $this->countLiveRevisions() - $this->countRevisionsWithComments(); |
|
| 175 | + return $this->countLiveRevisions()-$this->countRevisionsWithComments(); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function countAllPagesEdited() |
| 213 | 213 | { |
| 214 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
| 214 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public function countPagesCreated() |
| 223 | 223 | { |
| 224 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
| 224 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | } elseif ($block['log_action'] === 'unblock') { |
| 364 | 364 | // The last block was lifted. So the duration will be the time from when the |
| 365 | 365 | // last block was set to the time of the unblock. |
| 366 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
| 366 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
| 367 | 367 | if ($timeSinceLastBlock > $this->longestBlockSeconds) { |
| 368 | 368 | $this->longestBlockSeconds = $timeSinceLastBlock; |
| 369 | 369 | |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | // The last block was modified. So we will adjust $lastBlock to include |
| 375 | 375 | // the difference of the duration of the new reblock and time since the last block. |
| 376 | 376 | // $lastBlock is left unchange if its duration was indefinite. |
| 377 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
| 378 | - $lastBlock[1] = $timeSinceLastBlock + $duration; |
|
| 377 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
| 378 | + $lastBlock[1] = $timeSinceLastBlock+$duration; |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Test if the last block is still active, and if so use the expiry as the duration. |
| 388 | - $lastBlockExpiry = $lastBlock[0] + $lastBlock[1]; |
|
| 388 | + $lastBlockExpiry = $lastBlock[0]+$lastBlock[1]; |
|
| 389 | 389 | if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) { |
| 390 | 390 | $this->longestBlockSeconds = $duration; |
| 391 | 391 | // Otherwise, test if the duration of the last block is now the longest overall. |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | // If invalid, $duration is left as null. |
| 427 | 427 | if (strtotime($durationStr)) { |
| 428 | 428 | $expiry = strtotime($durationStr, $timestamp); |
| 429 | - $duration = $expiry - $timestamp; |
|
| 429 | + $duration = $expiry-$timestamp; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | return [$timestamp, $duration]; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
| 504 | 504 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
| 505 | 505 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
| 506 | - return $import + $interwiki + $upload; |
|
| 506 | + return $import+$interwiki+$upload; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -627,9 +627,9 @@ discard block |
||
| 627 | 627 | public function approvals() |
| 628 | 628 | { |
| 629 | 629 | $logCounts = $this->getLogCounts(); |
| 630 | - $total = $logCounts['review-approve'] + |
|
| 631 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
| 632 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
| 630 | + $total = $logCounts['review-approve']+ |
|
| 631 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
| 632 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
| 633 | 633 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
| 634 | 634 | return $total; |
| 635 | 635 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $logCounts = $this->getLogCounts(); |
| 654 | 654 | $create2 = $logCounts['newusers-create2'] ?: 0; |
| 655 | 655 | $byemail = $logCounts['newusers-byemail'] ?: 0; |
| 656 | - return $create2 + $byemail; |
|
| 656 | + return $create2+$byemail; |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $totals = $this->getRepository()->getMonthCounts($this->project, $this->user); |
| 703 | 703 | $out = [ |
| 704 | - 'yearLabels' => [], // labels for years |
|
| 704 | + 'yearLabels' => [], // labels for years |
|
| 705 | 705 | 'monthLabels' => [], // labels for months |
| 706 | 706 | 'totals' => [], // actual totals, grouped by namespace, year and then month |
| 707 | 707 | ]; |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | $out['totals'][$ns][$total['year']] = []; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count']; |
|
| 732 | + $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count']; |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | $dateRange = new DatePeriod( |
@@ -739,8 +739,8 @@ discard block |
||
| 739 | 739 | ); |
| 740 | 740 | |
| 741 | 741 | foreach ($dateRange as $monthObj) { |
| 742 | - $year = (int) $monthObj->format('Y'); |
|
| 743 | - $month = (int) $monthObj->format('n'); |
|
| 742 | + $year = (int)$monthObj->format('Y'); |
|
| 743 | + $month = (int)$monthObj->format('n'); |
|
| 744 | 744 | |
| 745 | 745 | // Fill in labels |
| 746 | 746 | $out['monthLabels'][] = $monthObj->format('Y-m'); |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | ->globalEditCounts($this->user, $this->project); |
| 850 | 850 | if ($sorted) { |
| 851 | 851 | // Sort. |
| 852 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
| 853 | - return $b['total'] - $a['total']; |
|
| 852 | + uasort($this->globalEditCounts, function($a, $b) { |
|
| 853 | + return $b['total']-$a['total']; |
|
| 854 | 854 | }); |
| 855 | 855 | } |
| 856 | 856 | } |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
| 887 | 887 | } |
| 888 | 888 | $page = $project->getRepository() |
| 889 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
| 889 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
| 890 | 890 | $edit = new Edit($page, $revision); |
| 891 | 891 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
| 892 | 892 | } |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | */ |
| 904 | 904 | protected function getEditSizeData() |
| 905 | 905 | { |
| 906 | - if (! is_array($this->editSizeData)) { |
|
| 906 | + if (!is_array($this->editSizeData)) { |
|
| 907 | 907 | $this->editSizeData = $this->getRepository() |
| 908 | 908 | ->getEditSizeData($this->project, $this->user); |
| 909 | 909 | } |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | public function countSmallEdits() |
| 928 | 928 | { |
| 929 | 929 | $editSizeData = $this->getEditSizeData(); |
| 930 | - return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0; |
|
| 930 | + return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0; |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | public function countLargeEdits() |
| 938 | 938 | { |
| 939 | 939 | $editSizeData = $this->getEditSizeData(); |
| 940 | - return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0; |
|
| 940 | + return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | /** |