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 string $appId an App ID |
33
|
|
|
* @param string $appCode an App code |
34
|
|
|
* @param bool $useCIT use Customer Integration Testing environment (CIT) instead of production |
35
|
|
|
*/ |
36
|
|
|
public function __construct(ClientInterface $client, string $appId, string $appCode, bool $useCIT = false) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($client); |
39
|
|
|
|
40
|
|
|
$this->app_id = $appId; |
41
|
|
|
$this->app_code = $appCode; |
42
|
|
|
$this->useCIT = $useCIT; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function getName(): string |
49
|
|
|
{ |
50
|
|
|
return 'here'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getAppId(): string |
54
|
|
|
{ |
55
|
|
|
return $this->app_id; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getAppCode(): string |
59
|
|
|
{ |
60
|
|
|
return $this->app_code; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function isCitEnabled(): bool |
64
|
|
|
{ |
65
|
|
|
return $this->useCIT; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function getCredentials(): array |
72
|
|
|
{ |
73
|
|
|
return [ |
74
|
|
|
'app_id' => $this->getAppId(), |
75
|
|
|
'app_code' => $this->getAppCode(), |
76
|
|
|
]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function createDistanceMatrixQuery(): DistanceMatrixQueryInterface |
80
|
|
|
{ |
81
|
|
|
return new DistanceMatrixQuery($this); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function createRoutingQuery(): RoutingQueryInterface |
85
|
|
|
{ |
86
|
|
|
return new RoutingQuery($this); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function __toString() |
93
|
|
|
{ |
94
|
|
|
return $this->getName(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|