Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ArticleInfo often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ArticleInfo, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | class ArticleInfo extends Model |
||
| 17 | { |
||
| 18 | /** @var Container The application's DI container. */ |
||
| 19 | protected $container; |
||
| 20 | |||
| 21 | /** @var Page The page. */ |
||
| 22 | protected $page; |
||
| 23 | |||
| 24 | /** @var int Number of revisions that belong to the page. */ |
||
| 25 | protected $numRevisions; |
||
| 26 | |||
| 27 | /** @var int Maximum number of revisions to process, as configured. */ |
||
| 28 | protected $maxRevisions; |
||
| 29 | |||
| 30 | /** @var int Number of revisions that were actually processed. */ |
||
| 31 | protected $numRevisionsProcessed; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Various statistics about editors to the page. These are not User objects |
||
| 35 | * so as to preserve memory. |
||
| 36 | * @var mixed[] |
||
| 37 | */ |
||
| 38 | protected $editors; |
||
| 39 | |||
| 40 | /** @var mixed[] The top 10 editors to the page by number of edits. */ |
||
| 41 | protected $topTenEditorsByEdits; |
||
| 42 | |||
| 43 | /** @var mixed[] The top 10 editors to the page by added text. */ |
||
| 44 | protected $topTenEditorsByAdded; |
||
| 45 | |||
| 46 | /** @var int Number of edits made by the top 10 editors. */ |
||
| 47 | protected $topTenCount; |
||
| 48 | |||
| 49 | /** @var mixed[] Various statistics about bots that edited the page. */ |
||
| 50 | protected $bots; |
||
| 51 | |||
| 52 | /** @var int Number of edits made to the page by bots. */ |
||
| 53 | protected $botRevisionCount; |
||
| 54 | |||
| 55 | /** @var mixed[] Various counts about each individual year and month of the page's history. */ |
||
| 56 | protected $yearMonthCounts; |
||
| 57 | |||
| 58 | /** @var Edit The first edit to the page. */ |
||
| 59 | protected $firstEdit; |
||
| 60 | |||
| 61 | /** @var Edit The last edit to the page. */ |
||
| 62 | protected $lastEdit; |
||
| 63 | |||
| 64 | /** @var Edit Edit that made the largest addition by number of bytes. */ |
||
| 65 | protected $maxAddition; |
||
| 66 | |||
| 67 | /** @var Edit Edit that made the largest deletion by number of bytes. */ |
||
| 68 | protected $maxDeletion; |
||
| 69 | |||
| 70 | /** @var int[] Number of in and outgoing links and redirects to the page. */ |
||
| 71 | protected $linksAndRedirects; |
||
| 72 | |||
| 73 | /** @var string[] Assessments of the page (see Page::getAssessments). */ |
||
| 74 | protected $assessments; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Maximum number of edits that were created across all months. This is used as a comparison |
||
| 78 | * for the bar charts in the months section. |
||
| 79 | * @var int |
||
| 80 | */ |
||
| 81 | protected $maxEditsPerMonth; |
||
| 82 | |||
| 83 | /** @var string[] List of (semi-)automated tools that were used to edit the page. */ |
||
| 84 | protected $tools; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Total number of bytes added throughout the page's history. This is used as a comparison |
||
| 88 | * when computing the top 10 editors by added text. |
||
| 89 | * @var int |
||
| 90 | */ |
||
| 91 | protected $addedBytes = 0; |
||
| 92 | |||
| 93 | /** @var int Number of days between first and last edit. */ |
||
| 94 | protected $totalDays; |
||
| 95 | |||
| 96 | /** @var int Number of minor edits to the page. */ |
||
| 97 | protected $minorCount = 0; |
||
| 98 | |||
| 99 | /** @var int Number of anonymous edits to the page. */ |
||
| 100 | protected $anonCount = 0; |
||
| 101 | |||
| 102 | /** @var int Number of automated edits to the page. */ |
||
| 103 | protected $automatedCount = 0; |
||
| 104 | |||
| 105 | /** @var int Number of edits to the page that were reverted with the subsequent edit. */ |
||
| 106 | protected $revertCount = 0; |
||
| 107 | |||
| 108 | /** @var int[] The "edits per <time>" counts. */ |
||
| 109 | protected $countHistory = [ |
||
| 110 | 'day' => 0, |
||
| 111 | 'week' => 0, |
||
| 112 | 'month' => 0, |
||
| 113 | 'year' => 0 |
||
| 114 | ]; |
||
| 115 | |||
| 116 | /** @var string[] List of wikidata and Checkwiki errors. */ |
||
| 117 | protected $bugs; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * ArticleInfo constructor. |
||
| 121 | * @param Page $page The page to process. |
||
| 122 | * @param Container $container The DI container. |
||
| 123 | */ |
||
| 124 | 9 | public function __construct(Page $page, Container $container) |
|
| 133 | |||
| 134 | /** |
||
| 135 | * Shorthand to get the page's project. |
||
| 136 | * @return Project |
||
| 137 | * @codeCoverageIgnore |
||
| 138 | */ |
||
| 139 | public function getProject() |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Get the number of revisions belonging to the page. |
||
| 146 | * @return int |
||
| 147 | */ |
||
| 148 | 4 | public function getNumRevisions() |
|
| 155 | |||
| 156 | /** |
||
| 157 | * Get the maximum number of revisions that we should process. |
||
| 158 | * @return int |
||
| 159 | */ |
||
| 160 | 3 | public function getMaxRevisions() |
|
| 167 | |||
| 168 | /** |
||
| 169 | * Get the number of revisions that are actually getting processed. |
||
| 170 | * This goes by the app.max_page_revisions parameter, or the actual |
||
| 171 | * number of revisions, whichever is smaller. |
||
| 172 | * @return int |
||
| 173 | */ |
||
| 174 | 5 | public function getNumRevisionsProcessed() |
|
| 175 | { |
||
| 176 | 5 | if (isset($this->numRevisionsProcessed)) { |
|
| 177 | 3 | return $this->numRevisionsProcessed; |
|
| 178 | } |
||
| 179 | |||
| 180 | 2 | if ($this->tooManyRevisions()) { |
|
| 181 | 1 | $this->numRevisionsProcessed = $this->getMaxRevisions(); |
|
| 182 | } else { |
||
| 183 | 1 | $this->numRevisionsProcessed = $this->getNumRevisions(); |
|
| 184 | } |
||
| 185 | |||
| 186 | 2 | return $this->numRevisionsProcessed; |
|
| 187 | } |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Are there more revisions than we should process, based on the config? |
||
| 191 | * @return bool |
||
| 192 | */ |
||
| 193 | 3 | public function tooManyRevisions() |
|
| 197 | |||
| 198 | /** |
||
| 199 | * Fetch and store all the data we need to show the ArticleInfo view. |
||
| 200 | * @codeCoverageIgnore |
||
| 201 | */ |
||
| 202 | public function prepareData() |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Get the number of editors that edited the page. |
||
| 211 | * @return int |
||
| 212 | */ |
||
| 213 | 1 | public function getNumEditors() |
|
| 214 | { |
||
| 215 | 1 | return count($this->editors); |
|
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * Get the number of bots that edited the page. |
||
| 220 | * @return int |
||
| 221 | */ |
||
| 222 | public function getNumBots() |
||
| 223 | { |
||
| 224 | return count($this->getBots()); |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Get the number of days between the first and last edit. |
||
| 229 | * @return int |
||
| 230 | */ |
||
| 231 | 1 | public function getTotalDays() |
|
| 232 | { |
||
| 233 | 1 | if (isset($this->totalDays)) { |
|
| 234 | 1 | return $this->totalDays; |
|
| 235 | } |
||
| 236 | 1 | $dateFirst = $this->firstEdit->getTimestamp(); |
|
| 237 | 1 | $dateLast = $this->lastEdit->getTimestamp(); |
|
| 238 | 1 | $interval = date_diff($dateLast, $dateFirst, true); |
|
| 239 | 1 | $this->totalDays = $interval->format('%a'); |
|
| 240 | 1 | return $this->totalDays; |
|
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * Get the average number of days between edits to the page. |
||
| 245 | * @return double |
||
| 246 | */ |
||
| 247 | 1 | public function averageDaysPerEdit() |
|
| 248 | { |
||
| 249 | 1 | return round($this->getTotalDays() / $this->getNumRevisionsProcessed(), 1); |
|
| 250 | } |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Get the average number of edits per day to the page. |
||
| 254 | * @return double |
||
| 255 | */ |
||
| 256 | 1 | public function editsPerDay() |
|
| 257 | { |
||
| 258 | 1 | $editsPerDay = $this->getTotalDays() |
|
| 259 | 1 | ? $this->getNumRevisionsProcessed() / ($this->getTotalDays() / (365 / 12 / 24)) |
|
| 260 | 1 | : 0; |
|
| 261 | 1 | return round($editsPerDay, 1); |
|
| 262 | } |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Get the average number of edits per month to the page. |
||
| 266 | * @return double |
||
| 267 | */ |
||
| 268 | 1 | View Code Duplication | public function editsPerMonth() |
| 269 | { |
||
| 270 | 1 | $editsPerMonth = $this->getTotalDays() |
|
| 271 | 1 | ? $this->getNumRevisionsProcessed() / ($this->getTotalDays() / (365 / 12)) |
|
| 272 | 1 | : 0; |
|
| 273 | 1 | return min($this->getNumRevisionsProcessed(), round($editsPerMonth, 1)); |
|
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Get the average number of edits per year to the page. |
||
| 278 | * @return double |
||
| 279 | */ |
||
| 280 | 1 | View Code Duplication | public function editsPerYear() |
| 281 | { |
||
| 282 | 1 | $editsPerYear = $this->getTotalDays() |
|
| 283 | 1 | ? $this->getNumRevisionsProcessed() / ($this->getTotalDays() / 365) |
|
| 284 | 1 | : 0; |
|
| 285 | 1 | return min($this->getNumRevisionsProcessed(), round($editsPerYear, 1)); |
|
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Get the average number of edits per editor. |
||
| 290 | * @return double |
||
| 291 | */ |
||
| 292 | 1 | public function editsPerEditor() |
|
| 293 | { |
||
| 294 | 1 | return round($this->getNumRevisionsProcessed() / count($this->editors), 1); |
|
| 295 | } |
||
| 296 | |||
| 297 | /** |
||
| 298 | * Get the percentage of minor edits to the page. |
||
| 299 | * @return double |
||
| 300 | */ |
||
| 301 | 1 | public function minorPercentage() |
|
| 302 | { |
||
| 303 | 1 | return round( |
|
| 304 | 1 | ($this->minorCount / $this->getNumRevisionsProcessed()) * 100, |
|
| 305 | 1 | 1 |
|
| 306 | ); |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Get the percentage of anonymous edits to the page. |
||
| 311 | * @return double |
||
| 312 | */ |
||
| 313 | 1 | public function anonPercentage() |
|
| 314 | { |
||
| 315 | 1 | return round( |
|
| 316 | 1 | ($this->anonCount / $this->getNumRevisionsProcessed()) * 100, |
|
| 317 | 1 | 1 |
|
| 318 | ); |
||
| 319 | } |
||
| 320 | |||
| 321 | /** |
||
| 322 | * Get the percentage of edits made by the top 10 editors. |
||
| 323 | * @return double |
||
| 324 | */ |
||
| 325 | 1 | public function topTenPercentage() |
|
| 326 | { |
||
| 327 | 1 | return round(($this->topTenCount / $this->getNumRevisionsProcessed()) * 100, 1); |
|
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Get the number of times the page has been viewed in the given timeframe. |
||
| 332 | * @param int $latest Last N days. |
||
| 333 | * @return int |
||
| 334 | */ |
||
| 335 | public function getPageviews($latest) |
||
| 339 | |||
| 340 | /** |
||
| 341 | * Get the page assessments of the page. |
||
| 342 | * @see https://www.mediawiki.org/wiki/Extension:PageAssessments |
||
| 343 | * @return string[]|false False if unsupported. |
||
| 344 | * @codeCoverageIgnore |
||
| 345 | */ |
||
| 346 | public function getAssessments() |
||
| 347 | { |
||
| 348 | if (!is_array($this->assessments)) { |
||
| 349 | $this->assessments = $this->page->getAssessments(); |
||
| 350 | } |
||
| 351 | return $this->assessments; |
||
| 353 | |||
| 354 | /** |
||
| 355 | * Get the number of automated edits made to the page. |
||
| 356 | * @return int |
||
| 357 | */ |
||
| 358 | 1 | public function getAutomatedCount() |
|
| 362 | |||
| 363 | /** |
||
| 364 | * Get the number of edits to the page that were reverted with the subsequent edit. |
||
| 365 | * @return int |
||
| 366 | */ |
||
| 367 | 1 | public function getRevertCount() |
|
| 371 | |||
| 372 | /** |
||
| 373 | * Get the number of edits to the page made by logged out users. |
||
| 374 | * @return int |
||
| 375 | */ |
||
| 376 | 1 | public function getAnonCount() |
|
| 380 | |||
| 381 | /** |
||
| 382 | * Get the number of minor edits to the page. |
||
| 383 | * @return int |
||
| 384 | */ |
||
| 385 | 1 | public function getMinorCount() |
|
| 389 | |||
| 390 | /** |
||
| 391 | * Get the number of edits to the page made in the past day, week, month and year. |
||
| 392 | * @return int[] With keys 'day', 'week', 'month' and 'year'. |
||
| 393 | */ |
||
| 394 | public function getCountHistory() |
||
| 398 | |||
| 399 | /** |
||
| 400 | * Get the number of edits to the page made by the top 10 editors. |
||
| 401 | * @return int |
||
| 402 | */ |
||
| 403 | 1 | public function getTopTenCount() |
|
| 407 | |||
| 408 | /** |
||
| 409 | * Get the first edit to the page. |
||
| 410 | * @return Edit |
||
| 411 | */ |
||
| 412 | public function getFirstEdit() |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Get the last edit to the page. |
||
| 419 | * @return Edit |
||
| 420 | */ |
||
| 421 | 1 | public function getLastEdit() |
|
| 425 | |||
| 426 | /** |
||
| 427 | * Get the edit that made the largest addition to the page (by number of bytes). |
||
| 428 | * @return Edit |
||
| 429 | */ |
||
| 430 | 1 | public function getMaxAddition() |
|
| 434 | |||
| 435 | /** |
||
| 436 | * Get the edit that made the largest removal to the page (by number of bytes). |
||
| 437 | * @return Edit |
||
| 438 | */ |
||
| 439 | 1 | public function getMaxDeletion() |
|
| 443 | |||
| 444 | /** |
||
| 445 | * Get the list of editors to the page, including various statistics. |
||
| 446 | * @return mixed[] |
||
| 447 | */ |
||
| 448 | 1 | public function getEditors() |
|
| 452 | |||
| 453 | /** |
||
| 454 | * Get the list of the top editors to the page (by edits), including various statistics. |
||
| 455 | * @return mixed[] |
||
| 456 | */ |
||
| 457 | 1 | public function topTenEditorsByEdits() |
|
| 461 | |||
| 462 | /** |
||
| 463 | * Get the list of the top editors to the page (by added text), including various statistics. |
||
| 464 | * @return mixed[] |
||
| 465 | */ |
||
| 466 | 1 | public function topTenEditorsByAdded() |
|
| 470 | |||
| 471 | /** |
||
| 472 | * Get various counts about each individual year and month of the page's history. |
||
| 473 | * @return mixed[] |
||
| 474 | */ |
||
| 475 | 2 | public function getYearMonthCounts() |
|
| 479 | |||
| 480 | /** |
||
| 481 | * Get the maximum number of edits that were created across all months. This is used as a |
||
| 482 | * comparison for the bar charts in the months section. |
||
| 483 | * @return int |
||
| 484 | */ |
||
| 485 | 1 | public function getMaxEditsPerMonth() |
|
| 489 | |||
| 490 | /** |
||
| 491 | * Get a list of (semi-)automated tools that were used to edit the page, including |
||
| 492 | * the number of times they were used, and a link to the tool's homepage. |
||
| 493 | * @return mixed[] |
||
| 494 | */ |
||
| 495 | 1 | public function getTools() |
|
| 499 | |||
| 500 | /** |
||
| 501 | * Get the list of page's wikidata and Checkwiki errors. |
||
| 502 | * @see Page::getErrors() |
||
| 503 | * @return string[] |
||
| 504 | */ |
||
| 505 | public function getBugs() |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Get the number of wikidata nad CheckWiki errors. |
||
| 515 | * @return int |
||
| 516 | */ |
||
| 517 | public function numBugs() |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Get the number of external links on the page. |
||
| 524 | * @return int |
||
| 525 | */ |
||
| 526 | 1 | public function linksExtCount() |
|
| 530 | |||
| 531 | /** |
||
| 532 | * Get the number of incoming links to the page. |
||
| 533 | * @return int |
||
| 534 | */ |
||
| 535 | 1 | public function linksInCount() |
|
| 539 | |||
| 540 | /** |
||
| 541 | * Get the number of outgoing links from the page. |
||
| 542 | * @return int |
||
| 543 | */ |
||
| 544 | 1 | public function linksOutCount() |
|
| 548 | |||
| 549 | /** |
||
| 550 | * Get the number of redirects to the page. |
||
| 551 | * @return int |
||
| 552 | */ |
||
| 553 | 1 | public function redirectsCount() |
|
| 557 | |||
| 558 | /** |
||
| 559 | * Get the number of external, incoming and outgoing links, along with |
||
| 560 | * the number of redirects to the page. |
||
| 561 | * @return int |
||
| 562 | * @codeCoverageIgnore |
||
| 563 | */ |
||
| 564 | private function getLinksAndRedirects() |
||
| 571 | |||
| 572 | /** |
||
| 573 | * Parse the revision history, collecting our core statistics. |
||
| 574 | * @return mixed[] Associative "master" array of metadata about the page. |
||
| 575 | * |
||
| 576 | * Untestable because it relies on getting a PDO statement. All the important |
||
| 577 | * logic lives in other methods which are tested. |
||
| 578 | * @codeCoverageIgnore |
||
| 579 | */ |
||
| 580 | private function parseHistory() |
||
| 636 | |||
| 637 | /** |
||
| 638 | * Update various counts based on the current edit. |
||
| 639 | * @param Edit $edit |
||
| 640 | * @param Edit[] $prevEdits With 'prev', 'maxAddition' and 'maxDeletion' |
||
| 641 | * @return Edit[] Updated version of $prevEdits. |
||
| 642 | */ |
||
| 643 | 3 | private function updateCounts(Edit $edit, $prevEdits) |
|
| 670 | |||
| 671 | /** |
||
| 672 | * Update various figures about content sizes based on the given edit. |
||
| 673 | * @param Edit $edit |
||
| 674 | * @param Edit[] $prevEdits With 'prev', 'maxAddition' and 'maxDeletion' |
||
| 675 | * @return Edit[] Updated version of $prevEdits. |
||
| 676 | */ |
||
| 677 | 3 | private function updateContentSizes(Edit $edit, $prevEdits) |
|
| 686 | |||
| 687 | /** |
||
| 688 | * Updates the figures on content sizes assuming the given edit was a revert of the previous one. |
||
| 689 | * In such a case, we don't want to treat the previous edit as legit content addition or removal. |
||
| 690 | * @param Edit[] $prevEdits With 'prev', 'maxAddition' and 'maxDeletion'. |
||
| 691 | * @return Edit[] Updated version of $prevEdits, for tracking. |
||
| 692 | */ |
||
| 693 | 3 | private function updateContentSizesRevert($prevEdits) |
|
| 714 | |||
| 715 | /** |
||
| 716 | * Updates the figures on content sizes assuming the given edit |
||
| 717 | * was NOT a revert of the previous edit. |
||
| 718 | * @param Edit $edit |
||
| 719 | * @param Edit[] $prevEdits With 'prev', 'maxAddition' and 'maxDeletion'. |
||
| 720 | * @return Edit[] Updated version of $prevEdits, for tracking. |
||
| 721 | */ |
||
| 722 | 3 | private function updateContentSizesNonRevert(Edit $edit, $prevEdits) |
|
| 749 | |||
| 750 | /** |
||
| 751 | * Get the size of the given edit, based on the previous edit (if present). |
||
| 752 | * We also don't return the actual edit size if last revision had a length of null. |
||
| 753 | * This happens when the edit follows other edits that were revision-deleted. |
||
| 754 | * @see T148857 for more information. |
||
| 755 | * @todo Remove once T101631 is resolved. |
||
| 756 | * @param Edit $edit |
||
| 757 | * @param Edit[] $prevEdits With 'prev', 'maxAddition' and 'maxDeletion'. |
||
| 758 | * @return Edit[] Updated version of $prevEdits, for tracking. |
||
| 759 | */ |
||
| 760 | 3 | private function getEditSize(Edit $edit, $prevEdits) |
|
| 768 | |||
| 769 | /** |
||
| 770 | * Update counts of automated tool usage for the given edit. |
||
| 771 | * @param Edit $edit |
||
| 772 | */ |
||
| 773 | 3 | private function updateToolCounts(Edit $edit) |
|
| 798 | |||
| 799 | /** |
||
| 800 | * Update various counts for the year and month of the given edit. |
||
| 801 | * @param Edit $edit |
||
| 802 | */ |
||
| 803 | 3 | private function updateYearMonthCounts(Edit $edit) |
|
| 825 | |||
| 826 | /** |
||
| 827 | * Add a new entry to $this->yearMonthCounts for the given year, |
||
| 828 | * with blank values for each month. This called during self::parseHistory(). |
||
| 829 | * @param Edit $edit |
||
| 830 | */ |
||
| 831 | 3 | private function addYearMonthCountEntry(Edit $edit) |
|
| 864 | |||
| 865 | /** |
||
| 866 | * Update the counts of anon and minor edits for year, month, |
||
| 867 | * and user of the given edit. |
||
| 868 | * @param Edit $edit |
||
| 869 | */ |
||
| 870 | 3 | private function updateAnonMinorCounts(Edit $edit) |
|
| 889 | |||
| 890 | /** |
||
| 891 | * Update various counts for the user of the given edit. |
||
| 892 | * @param Edit $edit |
||
| 893 | */ |
||
| 894 | 3 | private function updateUserCounts(Edit $edit) |
|
| 926 | |||
| 927 | /** |
||
| 928 | * Increment "edits per <time>" counts based on the given edit. |
||
| 929 | * @param Edit $edit |
||
| 930 | */ |
||
| 931 | 3 | private function updateCountHistory(Edit $edit) |
|
| 948 | |||
| 949 | /** |
||
| 950 | * Get info about bots that edited the page. |
||
| 951 | * @return mixed[] Contains the bot's username, edit count to the page, |
||
| 952 | * and whether or not they are currently a bot. |
||
| 953 | */ |
||
| 954 | public function getBots() |
||
| 978 | |||
| 979 | /** |
||
| 980 | * Number of edits made to the page by current or former bots. |
||
| 981 | * @param string[] $bots Used only in unit tests, where we |
||
| 982 | * supply mock data for the bots that will get processed. |
||
| 983 | * @return int |
||
| 984 | */ |
||
| 985 | 1 | public function getBotRevisionCount($bots = null) |
|
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Query for log events during each year of the article's history, |
||
| 1007 | * and set the results in $this->yearMonthCounts. |
||
| 1008 | */ |
||
| 1009 | 1 | private function setLogsEvents() |
|
| 1049 | |||
| 1050 | /** |
||
| 1051 | * Set statistics about the top 10 editors by added text and number of edits. |
||
| 1052 | * This is ran *after* parseHistory() since we need the grand totals first. |
||
| 1053 | * Various stats are also set for each editor in $this->editors to be used in the charts. |
||
| 1054 | * @return integer Number of edits |
||
| 1055 | */ |
||
| 1056 | 3 | private function setTopTenCounts() |
|
| 1125 | } |
||
| 1126 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: