This library is a PHP 7.1 library dedicated to lookup HTTP reason phrases. It is using the reason phrases list from the Guzzle PSR-7 package.
<?php
use CodeInc\Psr7ResponseSender\HttpReasonPhraseLookup;
// you can lookup a given status code
HttpReasonPhraseLookup::getReasonPhrase(404); // returns 'Not Found'
HttpReasonPhraseLookup::getReasonPhrase(999); // returns null
// or list all the reason phrases
foreach (HttpReasonPhraseLookup::getReasonPhrases() as $statusCode => $reasonPhrase) {
echo "$statusCode => $reasonPhrase\n";
}
This library is available through Packagist and can be installed using Composer:
composer require codeinc/http-reason-phrase-lookup
This library is published under the MIT license (see the LICENSE
file).