GoogleMaps::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace DH\NavigationBundle\Provider\GoogleMaps;
4
5
use DH\NavigationBundle\Contract\DistanceMatrix\DistanceMatrixQueryInterface;
6
use DH\NavigationBundle\Provider\AbstractProvider;
7
use DH\NavigationBundle\Provider\GoogleMaps\DistanceMatrix\DistanceMatrixQuery;
8
use GuzzleHttp\ClientInterface;
9
10
class GoogleMaps extends AbstractProvider
11
{
12
    /**
13
     * @var string
14
     */
15
    private $api_key;
16
17
    /**
18
     * @var string|null
19
     */
20
    private $region;
21
22
    /**
23
     * Here constructor.
24
     *
25
     * @param string      $apiKey an Api key
26
     * @param string|null $region region
27
     */
28
    public function __construct(ClientInterface $client, string $apiKey, ?string $region = null)
29
    {
30
        parent::__construct($client);
31
32
        $this->api_key = $apiKey;
33
        $this->region = $region;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getName(): string
40
    {
41
        return 'google_maps';
42
    }
43
44
    public function getApiKey(): string
45
    {
46
        return $this->api_key;
47
    }
48
49
    public function getRegion(): ?string
50
    {
51
        return $this->region;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getCredentials(): array
58
    {
59
        return [
60
            'key' => $this->getApiKey(),
61
        ];
62
    }
63
64
    public function createDistanceMatrixQuery(): DistanceMatrixQueryInterface
65
    {
66
        return new DistanceMatrixQuery($this);
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function __toString()
73
    {
74
        return $this->getName();
75
    }
76
}
77