Completed
Push — mawiki ( ed8c52 )
by Jeroen De
08:10
created

InMemoryGeocoder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Maps\Geocoders;
4
5
use DataValues\Geo\Values\LatLongValue;
6
7
/**
8
 * @since 3.8
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class InMemoryGeocoder implements Geocoder {
14
15
	private $locations;
16
17
	/**
18
	 * @param LatLongValue[] $locations
19
	 */
20
	public function __construct( array $locations ) {
21
		$this->locations = $locations;
22
	}
23
24
	/**
25
	 * @param string $address
26
	 *
27
	 * @return LatLongValue|null
28
	 */
29
	public function geocode( $address ) {
30
		if ( array_key_exists( $address, $this->locations ) ) {
31
			return $this->locations[$address];
32
		}
33
34
		return null;
35
	}
36
37
}
38