1 | <?php |
||
13 | class StatusCodeParser implements RobotsTxtInterface |
||
14 | { |
||
15 | use DirectiveParserCommons; |
||
16 | |||
17 | /** |
||
18 | * Valid schemes |
||
19 | */ |
||
20 | const VALID_SCHEME = [ |
||
21 | 'http', |
||
22 | 'https', |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Replacement coded |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $unofficialCodes = [ |
||
30 | 522 => 408, // CloudFlare could not negotiate a TCP handshake with the origin server. |
||
31 | 523 => 404, // CloudFlare could not reach the origin server; for example, if the DNS records for the baseUrl server are incorrect. |
||
32 | 524 => 408, // CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Status code |
||
37 | * @var int |
||
38 | */ |
||
39 | private $code; |
||
40 | |||
41 | /** |
||
42 | * Scheme |
||
43 | * @var string|false |
||
44 | */ |
||
45 | private $scheme; |
||
46 | |||
47 | /** |
||
48 | * Applicable |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $applicable; |
||
52 | |||
53 | /** |
||
54 | * Constructor |
||
55 | * |
||
56 | * @param int|null $code - HTTP status code |
||
57 | * @param string|false $scheme |
||
58 | * @throws StatusCodeException |
||
59 | */ |
||
60 | public function __construct($code, $scheme) |
||
66 | |||
67 | /** |
||
68 | * Check if URL is Applicable for Status code parsing |
||
69 | * |
||
70 | * @return bool |
||
71 | * @throws StatusCodeException |
||
72 | */ |
||
73 | private function isApplicable() |
||
88 | |||
89 | /** |
||
90 | * Replace unofficial code |
||
91 | * |
||
92 | * @param int[] $codePairs |
||
93 | * @return int |
||
94 | */ |
||
95 | public function codeOverride($codePairs = []) |
||
103 | |||
104 | /** |
||
105 | * Check |
||
106 | * |
||
107 | * @return string|null |
||
108 | */ |
||
109 | public function accessOverrideCheck() |
||
123 | } |
||
124 |