HTTP Status Provider Traits
Introduction
Traits in the GanbaroDigital\HttpStatus\StatusProviders
namespace will add various HTTP status codes to your classes. There's one trait per supported HTTP status code.
How To Use
Decide which HTTP status code you want to use, and import the corresponding trait:
// import the HttpStatusProvider interface
// and the trait for the HTTP status code of your choice
use GanbaroDigital\HttpStatus\Interfaces\HttpStatusProvider;
use GanbaroDigital\HttpStatus\StatusProviders\Informational\ContinueStatusProvider;
// implement the HttpStatusProvider interface, so that other code
// can detect that your class has the getHttpStatus() method
class MyClass implements HttpStatusProvider
{
// add the trait to your class
use ContinueStatusProvider;
}
$obj = new MyClass;
$httpStatus = $obj->getHttpStatus();
Informational Status Codes
These traits add the following HTTP 1xx status codes to your code:
Successful Status Codes
These traits add the following HTTP 2xx status codes to your code:
Redirection Status Codes
These traits add the following HTTP 3xx status codes to your code:
RequestError Status Codes
These traits add the following HTTP 4xx status codes to your code:
RuntimeError Status Codes
These traits add the following HTTP 5xx status codes to your code: