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

InMemoryGeocoder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A geocode() 0 7 2
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