frankdejonge / http-status-in-range
Utility to check if a HTTP status code is present in a given range.
Installs: 1 797
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^7.2
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-199HTTP_SUCCESS
200-299HTTP_REDIRECT
300-399HTTP_CLIENT_ERROR
400-499HTTP_SERVER_ERROR
500-599