Completed
Push — master ( 632d95...756717 )
by Jeroen De
13:02 queued 12:55
created

MapsOldGeocoderAdapter::geocode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Maps\Geocoders\Geocoder;
4
5
/**
6
 * Adapts the new Maps\Geocoders\Geocoder interface to the legacy
7
 * Maps\Geocoder class hierarchy.
8
 *
9
 * @since 3.8
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 */
14
final class MapsOldGeocoderAdapter extends \Maps\Geocoder {
15
16
	private $geocoder;
17
18
	/**
19
	 * @param Geocoder $geocoder
20
	 * @param string $identifier
21
	 */
22 2
	public function __construct( Geocoder $geocoder, $identifier ) {
23 2
		$this->geocoder = $geocoder;
24
25 2
		parent::__construct( $identifier );
26 2
	}
27
28 2
	public function geocode( $address ) {
29 2
		$result = $this->geocoder->geocode( $address );
30
31 2
		if ( $result === null ) {
32 1
			return false;
33
		}
34
35
		return [
36 1
			'lat' => $result->getLatitude(),
37 1
			'lon' => $result->getLongitude(),
38 1
		];
39
	}
40
41
	protected function getRequestUrl( $address ) {}
42
43
	protected function parseResponse( $response ) {}
44
45
}
46