TitleParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A stringParse() 0 9 2
1
<?php
2
3
namespace ParamProcessor;
4
5
use ValueParsers\ParseException;
6
use ValueParsers\StringValueParser;
7
8
/**
9
 * ValueParser that parses the string representation of a MediaWiki Title object.
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
class TitleParser extends StringValueParser {
15
16
	/**
17
	 * @see StringValueParser::stringParse
18
	 *
19
	 * @since 0.1
20
	 *
21
	 * @param string $value
22
	 *
23
	 * @return MediaWikiTitleValue
24
	 * @throws ParseException
25
	 */
26 8
	protected function stringParse( $value ) {
27 8
		$value = \Title::newFromText( $value );
28
29 8
		if ( is_null( $value ) ) {
30 2
			throw new ParseException( 'Not a title' );
31
		}
32
33 8
		return new MediaWikiTitleValue( $value );
34
	}
35
36
}