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 = []) |
||
102 | |||
103 | /** |
||
104 | * HTTP header encoding |
||
105 | * |
||
106 | * @param array $headers |
||
107 | * @return string |
||
108 | */ |
||
109 | protected function headerEncoding(array $headers) |
||
124 | |||
125 | /** |
||
126 | * Manually detect encoding |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | protected function detectEncoding() |
||
137 | |||
138 | /** |
||
139 | * URL content |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getContents() |
||
147 | |||
148 | /** |
||
149 | * Parser client |
||
150 | * |
||
151 | * @param int|null $byteLimit |
||
152 | * @return Client |
||
153 | */ |
||
154 | public function parserClient($byteLimit = self::BYTE_LIMIT) |
||
164 | |||
165 | /** |
||
166 | * Status code |
||
167 | * |
||
168 | * @return int |
||
169 | */ |
||
170 | public function getStatusCode() |
||
174 | |||
175 | /** |
||
176 | * Encoding |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getEncoding() |
||
184 | |||
185 | /** |
||
186 | * Next update timestamp |
||
187 | * |
||
188 | * @return \DateTime|false |
||
189 | */ |
||
190 | public function nextUpdate() |
||
196 | |||
197 | /** |
||
198 | * Valid until timestamp |
||
199 | * |
||
200 | * @return \DateTime|false |
||
201 | */ |
||
202 | public function validUntil() |
||
208 | } |
||
209 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.