Completed
Push — master ( 58dd05...6b6b52 )
by Carlos
01:57
created

GeoClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getStreet() 0 8 1
A callGeoService() 0 5 1
1
<?php
2
3
namespace Afonso\Emt;
4
5
use RuntimeException;
6
7
/**
8
 * The SDK client for the EMT OpenData API GEO service.
9
 *
10
 * @author Carlos Afonso Pérez <[email protected]>
11
 */
12
class GeoClient extends Client
13
{
14
    /**
15
     * Return stops around a given address as well as lines that serve those
16
     * stops.
17
     *
18
     * @var string $streetName
19
     * @var int $streetNumber
20
     * @return \stdClass
21
     * @throws \RuntimeException
22
     */
23 3
    public function getStreet($streetName, $streetNumber)
24
    {
25
        $params = [
26 3
            'description' => $streetName,
27 3
            'streetNumber' => $streetNumber,
28 1
        ];
29 3
        return $this->callGeoService('GetStreet.php', $params);
30
    }
31
32
    /**
33
     * Make an arbitrary call to the GEO service.
34
     *
35
     * @param string $endpoint
36
     * @param array $params
37
     * @return \stdClass
38
     */
39 3
    protected function callGeoService($endpoint, array $params = [])
40
    {
41 3
        $url = self::ENDPOINT . '/emt-proxy-server/last/geo/' . $endpoint;
42 3
        return $this->launcher->launchRequest($url, $params);
43
    }
44
}
45