1 | <?php |
||
12 | class StatusCodeParser implements RobotsTxtInterface |
||
13 | { |
||
14 | /** |
||
15 | * Valid schemes |
||
16 | */ |
||
17 | const VALID_SCHEME = [ |
||
18 | 'http', |
||
19 | 'https', |
||
20 | ]; |
||
21 | |||
22 | /** |
||
23 | * Status code |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $code = 200; |
||
27 | |||
28 | /** |
||
29 | * Scheme |
||
30 | * @var string|false|null |
||
31 | */ |
||
32 | protected $scheme; |
||
33 | |||
34 | /** |
||
35 | * Applicable |
||
36 | * @var bool |
||
37 | */ |
||
38 | protected $applicable; |
||
39 | |||
40 | /** |
||
41 | * Replacement coded |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $unofficialCodes = [ |
||
45 | 522 => 408, // CloudFlare could not negotiate a TCP handshake with the origin server. |
||
46 | 523 => 404, // CloudFlare could not reach the origin server; for example, if the DNS records for the baseUrl server are incorrect. |
||
47 | 524 => 408, // CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * Constructor |
||
52 | * |
||
53 | * @param integer|null $code - HTTP status code |
||
54 | * @param string|false|null $scheme |
||
55 | * @throws StatusCodeException |
||
56 | */ |
||
57 | public function __construct($code, $scheme) |
||
63 | |||
64 | /** |
||
65 | * Check if URL is Applicable for Status code parsing |
||
66 | * |
||
67 | * @return bool |
||
68 | * @throws StatusCodeException |
||
69 | */ |
||
70 | protected function isApplicable() |
||
83 | |||
84 | /** |
||
85 | * Replace an unofficial code |
||
86 | * |
||
87 | * @return int|false |
||
88 | */ |
||
89 | public function replaceUnofficial() |
||
97 | |||
98 | /** |
||
99 | * Determine the correct group |
||
100 | * |
||
101 | * @return string|null |
||
102 | */ |
||
103 | public function check() |
||
116 | } |
||
117 |