Geocoder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 17
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLocationByCoordinates() 0 5 1
A getLocationByAddress() 0 3 1
A getProviderName() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CodeblogPro\GeoCoder;
6
7
use CodeblogPro\GeoCoordinates\Coordinates;
8
use CodeblogPro\GeoLocationAddress\LocationInterface;
9
use CodeblogPro\GeoCoder\Providers\ProviderInterface;
10
11
class Geocoder implements GeocoderInterface
12
{
13
    private ProviderInterface $provider;
14
    private string $locale;
15
16
    public function __construct(ProviderInterface $provider, string $locale = '')
17
    {
18
        $this->provider = $provider;
19
        $this->locale = $locale;
20
    }
21
22
    public function getLocationByCoordinates(float $latitude, float $longitude): LocationInterface
23
    {
24
        $coordinates = new Coordinates($latitude, $longitude);
25
26
        return $this->provider->getLocationByCoordinates($coordinates, $this->locale);
27
    }
28
29
    public function getLocationByAddress(string $address): LocationInterface
30
    {
31
        return $this->provider->getLocationByAddress($address);
32
    }
33
34
    public function getProviderName(): string
35
    {
36
        return $this->provider->getName();
37
    }
38
}
39