1 | <?php |
||
28 | abstract class AbstractHttpProvider extends AbstractProvider |
||
29 | { |
||
30 | /** |
||
31 | * @var HttpClient |
||
32 | */ |
||
33 | private $client; |
||
34 | |||
35 | /** |
||
36 | * @var MessageFactory |
||
37 | */ |
||
38 | private $messageFactory; |
||
39 | |||
40 | /** |
||
41 | * @param HttpClient $client |
||
42 | * @param MessageFactory|null $factory |
||
43 | */ |
||
44 | 1 | public function __construct(HttpClient $client, MessageFactory $factory = null) |
|
49 | |||
50 | /** |
||
51 | * Get URL and return contents. If content is empty, an exception will be thrown. |
||
52 | * |
||
53 | * @param string $url |
||
54 | * |
||
55 | * @return string |
||
56 | * |
||
57 | * @throws InvalidServerResponse |
||
58 | */ |
||
59 | protected function getUrlContents(string $url): string |
||
65 | |||
66 | /** |
||
67 | * @param string $url |
||
68 | * |
||
69 | * @return RequestInterface |
||
70 | */ |
||
71 | protected function getRequest(string $url): RequestInterface |
||
75 | |||
76 | /** |
||
77 | * Send request and return contents. If content is empty, an exception will be thrown. |
||
78 | * |
||
79 | * @param RequestInterface $request |
||
80 | * |
||
81 | * @return string |
||
82 | * |
||
83 | * @throws InvalidServerResponse |
||
84 | */ |
||
85 | protected function getParsedResponse(RequestInterface $request): string |
||
105 | |||
106 | /** |
||
107 | * Returns the HTTP adapter. |
||
108 | * |
||
109 | * @return HttpClient |
||
110 | */ |
||
111 | 1 | protected function getHttpClient(): HttpClient |
|
115 | |||
116 | /** |
||
117 | * @return MessageFactory |
||
118 | */ |
||
119 | protected function getMessageFactory(): MessageFactory |
||
123 | } |
||
124 |