RequestHeaderFieldsTooLargeStatusProvider
Description
RequestHeaderFieldsTooLargeStatusProvider
is a trait. It adds a getHttpStatus()
method to your entity, value object or exception. This method returns a HttpStatus
value object that represents the status HTTP 431 Request Header Fields Too Large.
RequestHeaderFieldsTooLargeStatusProvider
satisfies the HttpStatusProvider
and HttpException
interfaces.
Public Interface
RequestHeaderFieldsTooLargeStatusProvider
has the following public interface:
// RequestHeaderFieldsTooLargeStatusProvider lives in this namespace
namespace GanbaroDigital\HttpStatus\StatusProviders\RequestError;
// our return types
use GanbaroDigital\HttpStatus\StatusValues\RequestError\RequestHeaderFieldsTooLargeStatus;
trait RequestHeaderFieldsTooLargeStatusProvider
{
/**
* returns the HTTP status code that best represents this object
*
* @return RequestHeaderFieldsTooLargeStatus
*/
public function getHttpStatus();
}
How To Use
In Value Objects and Entities
Use this trait in any value object or entity that maps onto the HTTP 431 status.
use GanbaroDigital\HttpStatus\Interfaces\HttpStatusProvider;
use GanbaroDigital\HttpStatus\StatusProviders\RequestError\RequestHeaderFieldsTooLargeStatusProvider;
class MyValueObject implements HttpStatusProvider
{
// adds getHttpStatus()
use RequestHeaderFieldsTooLargeStatusProvider;
}
PHP does not let traits implement interfaces. Your value object or entity will need to implement the HttpStatusProvider
interface explicitly.
In Exceptions
Use this trait in any exception that maps onto the HTTP 431 status.
use GanbaroDigital\HttpStatus\Interfaces\HttpRequestErrorException;
use GanbaroDigital\HttpStatus\StatusProviders\RequestError\RequestHeaderFieldsTooLargeStatusProvider;
class MyException implements HttpRequestErrorException
{
// adds getHttpStatus()
use RequestHeaderFieldsTooLargeStatusProvider;
}
PHP does not let traits implement interfaces. Your value object or entity will need to implement the HttpRequestErrorException
interface explicitly.
Class Contract
Here is the contract for this class:
GanbaroDigital\HttpStatus\StatusProviders\RequestError\RequestHeaderFieldsTooLargeStatusProvider
[x] Can instantiate class that uses this trait
[x] Returns request header fields too large status
Class contracts are built from this class's unit tests.
Future releases of this class may add to this contract. New additions may include:
- clarifying existing behaviour (e.g. stricter contract around input or return types)
- add new behaviours (e.g. extra class methods)
When you use this class, you can only rely on the behaviours documented by this contract.
If you:
- find other ways to use this class,
- or depend on behaviours that are not covered by a unit test,
- or depend on undocumented internal states of this class,
... your code may not work in the future.
Notes
RequestHeaderFieldsTooLargeStatusProvider
returns a new instance ofRequestHeaderFieldsTooLargeStatus
each time you callgetHttpStatus()
.
See Also
RequestHeaderFieldsTooLargeStatus
- the HTTP status value object returned by this traitHttpStatusProvider
- interface that your value object or entity should implementHttpRequestErrorException
- interface that your exception should implement