1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMap\Service; |
13
|
|
|
|
14
|
|
|
use Http\Client\HttpClient; |
15
|
|
|
use Http\Message\MessageFactory; |
16
|
|
|
use Psr\Http\Message\RequestInterface as PsrRequestInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author GeLo <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
abstract class AbstractHttpService extends AbstractService |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var HttpClient |
25
|
|
|
*/ |
26
|
|
|
private $client; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var MessageFactory |
30
|
|
|
*/ |
31
|
|
|
private $messageFactory; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $url |
35
|
|
|
* @param HttpClient $client |
36
|
|
|
* @param MessageFactory $messageFactory |
37
|
|
|
*/ |
38
|
|
|
public function __construct($url, HttpClient $client, MessageFactory $messageFactory) |
39
|
|
|
{ |
40
|
|
|
parent::__construct($url); |
41
|
|
|
|
42
|
|
|
$this->setClient($client); |
43
|
|
|
$this->setMessageFactory($messageFactory); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return HttpClient |
48
|
|
|
*/ |
49
|
|
|
public function getClient() |
50
|
|
|
{ |
51
|
|
|
return $this->client; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param HttpClient $client |
56
|
|
|
*/ |
57
|
|
|
public function setClient(HttpClient $client) |
58
|
|
|
{ |
59
|
|
|
$this->client = $client; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return MessageFactory |
64
|
|
|
*/ |
65
|
|
|
public function getMessageFactory() |
66
|
|
|
{ |
67
|
|
|
return $this->messageFactory; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param MessageFactory $messageFactory |
72
|
|
|
*/ |
73
|
|
|
public function setMessageFactory(MessageFactory $messageFactory) |
74
|
|
|
{ |
75
|
|
|
$this->messageFactory = $messageFactory; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param RequestInterface $request |
80
|
|
|
* |
81
|
|
|
* @return PsrRequestInterface |
82
|
|
|
*/ |
83
|
|
|
protected function createRequest(RequestInterface $request) |
84
|
|
|
{ |
85
|
|
|
return $this->messageFactory->createRequest('GET', $this->createUrl($request)); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|