frankdejonge/http-status-in-range

Utility to check if a HTTP status code is present in a given range.

1.0.0 2018-06-28 07:54 UTC

This package is auto-updated.

Last update: 2024-11-06 11:04:03 UTC


README

composer require frankdejonge/http-status-in-range
<?php

use function FrankDeJonge\HttpStatusRange\http_status_in_range;
use function FrankDeJonge\HttpStatusRange\http_status_not_in_range;
use const FrankDeJonge\HttpStatusRange\HTTP_SUCCESS;

$response = $httpClient->get('/something');

if (http_status_in_range($response->getStatusCode(), HTTP_SUCCESS)) {
    // SUCCESS!
}

if (http_status_not_in_range($response->getStatusCode(), HTTP_SUCCESS)) {
    // NOT SUCCESS!
}

Ranges:

  • HTTP_INFORMATIONAL 100-199
  • HTTP_SUCCESS 200-299
  • HTTP_REDIRECT 300-399
  • HTTP_CLIENT_ERROR 400-499
  • HTTP_SERVER_ERROR 500-599