HTTP Status Provider Traits

Using The Traits

There's a trait for each supported HTTP status code. The full list of traits is here: HTTP Status Provider Traits.

Each trait is used exactly the same way:

// import the trait and associated interface
use GanbaroDigital\HttpStatus\StatusProviders\Informational\ContinueStatusProvider;
use GanbaroDigital\HttpStatus\Interfaces\HttpStatusProvider;

class MyValueObject implements HttpStatusProvider
{
    use ContinueStatusProvider;
}

Each trait adds a public method getHttpStatus() to your class:

/**
 * returns the HttpStatus that we have mapped onto
 *
 * @return HttpStatus
 */
public function getHttpStatus();

The trait that you pick decides which HTTP status that getHttpStatus() will return.