Completed
Push — vishual ( 73c053...0d0a79 )
by Jeroen De
06:15
created

PageContentFetcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Maps;
4
5
use MediaWiki\Storage\RevisionLookup;
6
7
/**
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
class PageContentFetcher {
12
13
	private $titleParser;
14
	private $revisionLookup;
15
16
	public function __construct( \TitleParser $titleParser, RevisionLookup $revisionLookup ) {
17
		$this->titleParser = $titleParser;
18
		$this->revisionLookup = $revisionLookup;
19
	}
20
21
	public function getPageContent( string $pageTitle, int $defaultNamespace )/*: ?\Content */{
22
		try {
23
			$title = $this->titleParser->parseTitle( $pageTitle, $defaultNamespace );
24
		}
25
		catch ( \MalformedTitleException $e ) {
0 ignored issues
show
Bug introduced by
The class MalformedTitleException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
26
			return null;
27
		}
28
29
		$revision = $this->revisionLookup->getRevisionByTitle( $title );
30
31
		if ( $revision === null ) {
32
			return null;
33
		}
34
35
		return $revision->getContent( 'main' );
36
	}
37
38
}
39