| 1 | <?php | ||
| 6 | class HttpStatusCodeParser | ||
| 7 | { | ||
| 8 | /** | ||
| 9 | * Status code | ||
| 10 | * @var int | ||
| 11 | */ | ||
| 12 | protected $code = 200; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Replacement coded | ||
| 16 | * @var array | ||
| 17 | */ | ||
| 18 | protected $unofficialCodes = [ | ||
| 19 | 522 => 408, // CloudFlare could not negotiate a TCP handshake with the origin server. | ||
| 20 | 523 => 404, // CloudFlare could not reach the origin server; for example, if the DNS records for the origin server are incorrect. | ||
| 21 | 524 => 408, // CloudFlare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response. | ||
| 22 | ]; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Constructor | ||
| 26 | * | ||
| 27 | * @param integer $code - HTTP status code | ||
| 28 | * @throws Exceptions\HttpStatusCodeException | ||
| 29 | */ | ||
| 30 | public function __construct($code) | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Replace an unofficial code | ||
| 43 | * | ||
| 44 | * @return int|false | ||
| 45 | */ | ||
| 46 | public function replaceUnofficial() | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Determine the correct group | ||
| 57 | * | ||
| 58 | * @return string | ||
| 59 | */ | ||
| 60 | public function isAllowed() | ||
| 68 | } | ||
| 69 |