1 | <?php |
||
19 | class GuzzleConnection implements Connection |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * GuzzleHttp Client instance. |
||
24 | * |
||
25 | * @var \GuzzleHttp\Client |
||
26 | */ |
||
27 | protected $guzzle; |
||
28 | |||
29 | /** |
||
30 | * Promise for GET request. |
||
31 | * |
||
32 | * @var \Psr\Http\Message\ResponseInterface |
||
33 | */ |
||
34 | protected $response; |
||
35 | |||
36 | /** |
||
37 | * Make instance for new Guzzle Client. |
||
38 | * |
||
39 | * @param int $timeout Timeout for request. |
||
40 | * @param string $userAgent Header for user agent. |
||
41 | * |
||
42 | * @return $this |
||
43 | */ |
||
44 | public function makeConnection($timeout = 30, $userAgent = "") |
||
52 | |||
53 | /** |
||
54 | * Make GET request. |
||
55 | * |
||
56 | * @param string $url Request URL. |
||
57 | * |
||
58 | * @return $this |
||
59 | * @throws \ComicVine\Exceptions\InvalidUrl |
||
60 | */ |
||
61 | public function setConnection($url) |
||
71 | |||
72 | /** |
||
73 | * Return response from request. |
||
74 | * |
||
75 | * @return mixed |
||
76 | * @throws \ComicVine\Exceptions\EmptyResponse |
||
77 | */ |
||
78 | public function getResult() |
||
84 | |||
85 | /** |
||
86 | * Return status code of request. |
||
87 | * |
||
88 | * @return mixed |
||
89 | * @throws \ComicVine\Exceptions\EmptyResponse |
||
90 | */ |
||
91 | public function getHttpStatus() |
||
97 | |||
98 | /** |
||
99 | * Check is response attribute is not empty. |
||
100 | * |
||
101 | * @throws \ComicVine\Exceptions\EmptyResponse |
||
102 | */ |
||
103 | protected function isNotEmptyResponse() |
||
109 | |||
110 | } |