GeocoderMock::geocode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 2
rs 10
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