GeocoderMock   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A geocode() 0 13 2
1
<?php
2
3
namespace Linder\Mock;
4
5
use OpenCage\Geocoder\AbstractGeocoder;
6
7
class GeocoderMock extends AbstractGeocoder
8
{
9
    /**
10
     * This method mocks OpenCage API
11
     * and only returns the Latitude and Longitude
12
     * of gothenburg which is default value
13
     * and status code if it fails or not.
14
     *
15
     * @param string $value
16
     *
17
     * @return array
18
     */
19 2
    public function geocode($search) : Array
20
    {
21 2
        $res = [];
22
23 2
        if ($search != "fail") {
24 2
            $res["results"][0]["geometry"]["lat"] = 57.708870;
25 2
            $res["results"][0]["geometry"]["lng"] = 11.974560;
26 2
            $res["status"]["code"] = 200;
27
        } else {
28 1
            $res["status"]["code"] = 400;
29
        }
30
31 2
        return $res;
32
    }
33
}
34