@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace App\Exception; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace App\Repository; |
| 6 | 6 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | $wikidataId = ltrim($page->getWikidataId(), 'Q'); |
| 307 | 307 | |
| 308 | - $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . " |
|
| 308 | + $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')." |
|
| 309 | 309 | FROM wikidatawiki_p.wb_items_per_site |
| 310 | 310 | WHERE ips_item_id = :wikidataId"; |
| 311 | 311 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | 'wikidataId' => $wikidataId, |
| 314 | 314 | ])->fetchAllAssociative(); |
| 315 | 315 | |
| 316 | - return $count ? (int) $result[0]['count'] : $result; |
|
| 316 | + return $count ? (int)$result[0]['count'] : $result; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | // Transform to associative array by 'type' |
| 353 | 353 | foreach ($res as $row) { |
| 354 | - $data[$row['type'] . '_count'] = (int)$row['value']; |
|
| 354 | + $data[$row['type'].'_count'] = (int)$row['value']; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | return $data; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | $project = $page->getProject()->getDomain(); |
| 400 | 400 | |
| 401 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
| 401 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
| 402 | 402 | "$project/all-access/user/$title/daily/$start/$end"; |
| 403 | 403 | |
| 404 | 404 | try { |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | ]); |
| 409 | 409 | $pageviews = json_decode($res->getBody()->getContents(), true); |
| 410 | 410 | return $pageviews; |
| 411 | - } catch (ServerException|ConnectException $e) { |
|
| 411 | + } catch (ServerException | ConnectException $e) { |
|
| 412 | 412 | return null; |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | { |
| 424 | 424 | if ($this->isWMF) { |
| 425 | 425 | $domain = $page->getProject()->getDomain(); |
| 426 | - $url = "https://$domain/api/rest_v1/page/html/" . urlencode(str_replace(' ', '_', $page->getTitle())); |
|
| 426 | + $url = "https://$domain/api/rest_v1/page/html/".urlencode(str_replace(' ', '_', $page->getTitle())); |
|
| 427 | 427 | if (null !== $revId) { |
| 428 | 428 | $url .= "/$revId"; |
| 429 | 429 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | $normalized = []; |
| 492 | 492 | if (isset($result['query']['normalized'])) { |
| 493 | 493 | array_map( |
| 494 | - function ($e) use (&$normalized): void { |
|
| 494 | + function($e) use (&$normalized): void { |
|
| 495 | 495 | $normalized[$e['to']] = $e['from']; |
| 496 | 496 | }, |
| 497 | 497 | $result['query']['normalized'] |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace App\Model; |
| 6 | 6 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $title = $info['title'] ?? $this->unnormalizedPageName; |
| 125 | 125 | $nsName = $this->getNamespaceName(); |
| 126 | 126 | return $nsName |
| 127 | - ? str_replace($nsName . ':', '', $title) |
|
| 127 | + ? str_replace($nsName.':', '', $title) |
|
| 128 | 128 | : $title; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $content = $this->repository->getPagesWikitext( |
| 324 | 324 | $this->getProject(), |
| 325 | - [ $this->getTitle() ] |
|
| 325 | + [$this->getTitle()] |
|
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | 328 | return $content[$this->getTitle()] ?? null; |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | $wikidataInfo = $this->repository->getWikidataInfo($this); |
| 390 | 390 | |
| 391 | - $terms = array_map(function ($entry) { |
|
| 391 | + $terms = array_map(function($entry) { |
|
| 392 | 392 | return $entry['term']; |
| 393 | 393 | }, $wikidataInfo); |
| 394 | 394 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | 'prio' => 2, |
| 400 | 400 | 'name' => 'Wikidata', |
| 401 | 401 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
| 402 | - 'explanation' => "See: <a target='_blank' " . |
|
| 402 | + 'explanation' => "See: <a target='_blank' ". |
|
| 403 | 403 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
| 404 | 404 | ]; |
| 405 | 405 | } |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | 'prio' => 3, |
| 410 | 410 | 'name' => 'Wikidata', |
| 411 | 411 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 412 | - 'explanation' => "See: <a target='_blank' " . |
|
| 412 | + 'explanation' => "See: <a target='_blank' ". |
|
| 413 | 413 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 414 | 414 | ]; |
| 415 | 415 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | return null; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - return array_sum(array_map(function ($item) { |
|
| 494 | + return array_sum(array_map(function($item) { |
|
| 495 | 495 | return (int)$item['views']; |
| 496 | 496 | }, $pageviews['items'])); |
| 497 | 497 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace App\Model; |
| 6 | 6 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | [$bytes, $chars, $words] = $this->countCharsAndWords($crawler); |
| 172 | 172 | |
| 173 | 173 | $refContent = []; |
| 174 | - $refs->each(function ($ref) use (&$refContent): void { |
|
| 174 | + $refs->each(function($ref) use (&$refContent): void { |
|
| 175 | 175 | $refContent[] = $ref->text(); |
| 176 | 176 | }); |
| 177 | 177 | $uniqueRefs = count(array_unique($refContent)); |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | '[typeof~="mw:Extension/templatestyles"]', |
| 207 | 207 | '[typeof~="mw:Extension/math"]', |
| 208 | 208 | '[typeof~="mw:Extension/ref"]', |
| 209 | - ]))->each(function (Crawler $subCrawler) { |
|
| 209 | + ]))->each(function(Crawler $subCrawler) { |
|
| 210 | 210 | foreach ($subCrawler as $subNode) { |
| 211 | 211 | $subNode->parentNode->removeChild($subNode); |
| 212 | 212 | } |
| 213 | 213 | }); |
| 214 | 214 | |
| 215 | - $paragraphs->each(function ($node) use (&$totalBytes, &$totalChars, &$totalWords): void { |
|
| 215 | + $paragraphs->each(function($node) use (&$totalBytes, &$totalChars, &$totalWords): void { |
|
| 216 | 216 | /** @var Crawler $node */ |
| 217 | 217 | $text = $node->text(); |
| 218 | 218 | $totalBytes += strlen($text); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $data = [ |
| 275 | 275 | 'project' => $project->getDomain(), |
| 276 | 276 | 'page' => $page->getTitle(), |
| 277 | - 'watchers' => (int) $page->getWatchers(), |
|
| 277 | + 'watchers' => (int)$page->getWatchers(), |
|
| 278 | 278 | 'pageviews' => $page->getLatestPageviews(), |
| 279 | 279 | 'pageviews_offset' => self::PAGEVIEWS_OFFSET, |
| 280 | 280 | ]; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | if ($info) { |
| 298 | 298 | $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']); |
| 299 | 299 | $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']); |
| 300 | - $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp(); |
|
| 300 | + $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp(); |
|
| 301 | 301 | |
| 302 | 302 | // Some wikis (such foundation.wikimedia.org) may be missing the creation date. |
| 303 | 303 | $creationDateTime = false === $creationDateTime |
@@ -309,16 +309,16 @@ discard block |
||
| 309 | 309 | ->getAssessment($page); |
| 310 | 310 | |
| 311 | 311 | $data = array_merge($data, [ |
| 312 | - 'revisions' => (int) $info['num_edits'], |
|
| 313 | - 'editors' => (int) $info['num_editors'], |
|
| 314 | - 'minor_edits' => (int) $info['minor_edits'], |
|
| 312 | + 'revisions' => (int)$info['num_edits'], |
|
| 313 | + 'editors' => (int)$info['num_editors'], |
|
| 314 | + 'minor_edits' => (int)$info['minor_edits'], |
|
| 315 | 315 | 'author' => $info['author'], |
| 316 | - 'author_editcount' => null === $info['author_editcount'] ? null : (int) $info['author_editcount'], |
|
| 316 | + 'author_editcount' => null === $info['author_editcount'] ? null : (int)$info['author_editcount'], |
|
| 317 | 317 | 'created_at' => $creationDateTime, |
| 318 | 318 | 'created_rev_id' => $info['created_rev_id'], |
| 319 | 319 | 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'), |
| 320 | 320 | 'secs_since_last_edit' => $secsSinceLastEdit, |
| 321 | - 'last_edit_id' => (int) $info['modified_rev_id'], |
|
| 321 | + 'last_edit_id' => (int)$info['modified_rev_id'], |
|
| 322 | 322 | 'assessment' => $assessment, |
| 323 | 323 | ]); |
| 324 | 324 | } |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Sort by edit count. |
| 471 | - uasort($this->bots, function ($a, $b) { |
|
| 472 | - return $b['count'] - $a['count']; |
|
| 471 | + uasort($this->bots, function($a, $b) { |
|
| 472 | + return $b['count']-$a['count']; |
|
| 473 | 473 | }); |
| 474 | 474 | |
| 475 | 475 | return $this->bots; |