1 | <?php |
||
14 | class Download implements RobotsTxtInterface |
||
15 | { |
||
16 | /** |
||
17 | * Base uri |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $baseUri; |
||
21 | |||
22 | /** |
||
23 | * Download time |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $time; |
||
27 | |||
28 | /** |
||
29 | * Robots.txt max-age |
||
30 | * @var int|null |
||
31 | */ |
||
32 | protected $maxAge = null; |
||
33 | |||
34 | /** |
||
35 | * HTTP Status code |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $statusCode; |
||
39 | |||
40 | /** |
||
41 | * Robots.txt contents |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $contents; |
||
45 | |||
46 | /** |
||
47 | * Robots.txt character encoding |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $encoding; |
||
51 | |||
52 | /** |
||
53 | * Parser client class |
||
54 | * @var Client |
||
55 | */ |
||
56 | protected $parserClient; |
||
57 | |||
58 | /** |
||
59 | * Download constructor. |
||
60 | * |
||
61 | * @param string $baseUri |
||
62 | * @param array $guzzleConfig |
||
63 | */ |
||
64 | public function __construct($baseUri, array $guzzleConfig = []) |
||
104 | |||
105 | /** |
||
106 | * Content-Type encoding HTTP header |
||
107 | * |
||
108 | * @param array $headers |
||
109 | * @return string |
||
110 | */ |
||
111 | protected function headerEncoding(array $headers) |
||
126 | |||
127 | /** |
||
128 | * Manually detect encoding |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | protected function detectEncoding() |
||
139 | |||
140 | /** |
||
141 | * URL content |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getContents() |
||
149 | |||
150 | /** |
||
151 | * Cache-Control max-age HTTP header |
||
152 | * |
||
153 | * @param array $headers |
||
154 | * @return integer |
||
155 | */ |
||
156 | protected function headerMaxAge(array $headers) |
||
169 | |||
170 | /** |
||
171 | * Parser client |
||
172 | * |
||
173 | * @param int|null $byteLimit |
||
174 | * @return Client |
||
175 | */ |
||
176 | public function parserClient($byteLimit = self::BYTE_LIMIT) |
||
183 | |||
184 | /** |
||
185 | * Status code |
||
186 | * |
||
187 | * @return int |
||
188 | */ |
||
189 | public function getStatusCode() |
||
193 | |||
194 | /** |
||
195 | * Encoding |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getEncoding() |
||
203 | |||
204 | /** |
||
205 | * Next update timestamp |
||
206 | * |
||
207 | * @return \DateTime|false |
||
208 | */ |
||
209 | public function nextUpdate() |
||
215 | |||
216 | /** |
||
217 | * Valid until timestamp |
||
218 | * |
||
219 | * @return \DateTime|false |
||
220 | */ |
||
221 | public function validUntil() |
||
227 | } |
||
228 |