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