1 | <?php declare(strict_types=1); |
||
25 | class Client implements ClientInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Default user agent provided with the package |
||
30 | */ |
||
31 | const DEFAULT_USER_AGENT = 'Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1'; |
||
32 | |||
33 | /** |
||
34 | * @var \GuzzleHttp\ClientInterface |
||
35 | */ |
||
36 | protected $guzzleClient; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $userAgent; |
||
42 | |||
43 | /** |
||
44 | * @param \GuzzleHttp\ClientInterface $guzzleClient |
||
45 | * @param string $userAgent |
||
46 | */ |
||
47 | 11 | public function __construct(\GuzzleHttp\ClientInterface $guzzleClient, string $userAgent = self::DEFAULT_USER_AGENT) |
|
52 | |||
53 | /** |
||
54 | * @param string $userAgent The new user-agent |
||
55 | * @return Client |
||
56 | */ |
||
57 | public function setUserAgent(string $userAgent) : Client |
||
63 | |||
64 | /** |
||
65 | * @param string $url |
||
66 | * @param \DateTime $modifiedSince |
||
67 | * @return ResponseInterface |
||
68 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
69 | */ |
||
70 | 3 | public function getResponse(string $url, \DateTime $modifiedSince) : ResponseInterface |
|
93 | 4 | ||
94 | 4 | /** |
|
95 | * @param float $start |
||
96 | 4 | * @return int |
|
97 | */ |
||
98 | protected function getDuration(float $start): int |
||
102 | /** |
||
103 | 4 | * @param iterable $requests |
|
104 | * @param ReaderInterface $reader |
||
105 | 4 | * @return \Generator |
|
106 | */ |
||
107 | 4 | public function getPromises(iterable $requests, ReaderInterface $reader) : \Generator |
|
113 | |||
114 | 4 | /** |
|
115 | 1 | * @param Request $request |
|
116 | 4 | * @param ReaderInterface $reader |
|
117 | * @return PromiseInterface |
||
118 | 4 | */ |
|
119 | protected function getPromise(Request $request, ReaderInterface $reader) : PromiseInterface |
||
136 | 7 | ||
137 | /** |
||
138 | * @param Request $request |
||
139 | * @return PromiseInterface |
||
140 | 7 | */ |
|
141 | 7 | protected function newPromise(Request $request) : PromiseInterface |
|
147 | |||
148 | /** |
||
149 | * @param \DateTime $modifiedSince |
||
150 | * @return array |
||
151 | */ |
||
152 | protected function getOptions(\DateTime $modifiedSince) : array |
||
162 | } |
||
163 |