Passed
Push — master ( d31a50...87284d )
by Damien
02:11
created

Here::createRoutingQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DH\NavigationBundle\Provider\Here;
4
5
use DH\NavigationBundle\Contract\DistanceMatrix\DistanceMatrixQueryInterface;
6
use DH\NavigationBundle\Contract\Routing\RoutingQueryInterface;
7
use DH\NavigationBundle\Provider\AbstractProvider;
8
use DH\NavigationBundle\Provider\Here\DistanceMatrix\DistanceMatrixQuery;
9
use DH\NavigationBundle\Provider\Here\Routing\RoutingQuery;
10
use GuzzleHttp\ClientInterface;
11
12
class Here extends AbstractProvider
13
{
14
    /**
15
     * @var string
16
     */
17
    private $app_id;
18
19
    /**
20
     * @var string
21
     */
22
    private $app_code;
23
24
    /**
25
     * @var bool
26
     */
27
    private $useCIT;
28
29
    /**
30
     * Here constructor.
31
     *
32
     * @param ClientInterface $client
33
     * @param string          $appId   an App ID
34
     * @param string          $appCode an App code
35
     * @param bool            $useCIT  use Customer Integration Testing environment (CIT) instead of production
36
     */
37
    public function __construct(ClientInterface $client, string $appId, string $appCode, bool $useCIT = false)
38
    {
39
        parent::__construct($client);
40
41
        $this->app_id = $appId;
42
        $this->app_code = $appCode;
43
        $this->useCIT = $useCIT;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getName(): string
50
    {
51
        return 'here';
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getAppId(): string
58
    {
59
        return $this->app_id;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getAppCode(): string
66
    {
67
        return $this->app_code;
68
    }
69
70
    /**
71
     * @return bool
72
     */
73
    public function isCitEnabled(): bool
74
    {
75
        return $this->useCIT;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function getCredentials(): array
82
    {
83
        return [
84
            'app_id' => $this->getAppId(),
85
            'app_code' => $this->getAppCode(),
86
        ];
87
    }
88
89
    /**
90
     * @return DistanceMatrixQueryInterface
91
     */
92
    public function createDistanceMatrixQuery(): DistanceMatrixQueryInterface
93
    {
94
        return new DistanceMatrixQuery($this);
95
    }
96
97
    /**
98
     * @return RoutingQueryInterface
99
     */
100
    public function createRoutingQuery(): RoutingQueryInterface
101
    {
102
        return new RoutingQuery($this);
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function __toString()
109
    {
110
        return $this->getName();
111
    }
112
}
113