Geocoder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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