Completed
Push — master ( f04bbc...eab9d5 )
by Jeroen De
07:09
created

DistanceParser   A

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
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

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