DistanceParser   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
declare( strict_types = 1 );
4
5
namespace Maps\WikitextParsers;
6
7
use ValueParsers\ParseException;
8
use ValueParsers\StringValueParser;
9
10
/**
11
 * ValueParser that parses the string representation of a distance.
12
 *
13
 * @since 3.0
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class DistanceParser extends StringValueParser {
19
20
	/**
21
	 * @see StringValueParser::stringParse
22
	 *
23
	 * @since 3.0
24
	 *
25
	 * @param string $value
26
	 *
27
	 * @return float
28
	 * @throws ParseException
29
	 */
30 83
	public function stringParse( $value ) {
31 83
		$distance = \Maps\Presentation\MapsDistanceParser::parseDistance( $value );
32
33 83
		if ( is_float( $distance ) ) {
34 73
			return $distance;
35
		}
36
37 10
		throw new ParseException( 'Not a distance' );
38
	}
39
40
}
41