Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/HttpRedirectException.php

This file was deleted.

16 changes: 16 additions & 0 deletions src/ResponseStatusException/AbstractResponseStatusException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\HttpException;

abstract class AbstractResponseStatusException extends HttpException {
public function __construct(string $message = "") {
parent::__construct(
$message,
$this->getHttpCode(),
null
);
}

abstract protected function getHttpCode():int;
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpBadGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The server was acting as a gateway or proxy and received an invalid response
* from the upstream server.
* @link https://httpstatuses.com/502
*/
class HttpBadGateway extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::BAD_GATEWAY;
}
}
16 changes: 16 additions & 0 deletions src/ResponseStatusException/HttpBadRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The server cannot or will not process the request due to an apparent client
* error (e.g., malformed request syntax, size too large, invalid request
* message framing, or deceptive request routing).
* @link https://httpstatuses.com/400
*/
class HttpBadRequest extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::BAD_REQUEST;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpConflict.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpConflict extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::CONFLICT;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpExpectationFailed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpExpectationFailed extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::EXPECTATION_FAILED;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpFailedDependency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpFailedDependency extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::FAILED_DEPENDENCY;
}
}
20 changes: 20 additions & 0 deletions src/ResponseStatusException/HttpForbidden.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The request contained valid data and was understood by the server, but the
* server is refusing action. This may be due to the user not having the
* necessary permissions for a resource or needing an account of some sort, or
* attempting a prohibited action (e.g. creating a duplicate record where only
* one is allowed). This code is also typically used if the request provided
* authentication via the WWW-Authenticate header field, but the server did not
* accept that authentication. The request should not be repeated.
* @link https://httpstatuses.com/403
*/
class HttpForbidden extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::FORBIDDEN;
}
}
21 changes: 21 additions & 0 deletions src/ResponseStatusException/HttpFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* Tells the client to look at (browse to) another URL. 302 has been superseded
* by 303 and 307. This is an example of industry practice contradicting the
* standard. The HTTP/1.0 specification (RFC 1945) required the client to
* perform a temporary redirect (the original describing phrase was
* "Moved Temporarily"), but popular browsers implemented 302 with the
* functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303
* and 307 to distinguish between the two behaviours. However, some Web
* applications and frameworks use the 302 status code as if it were the 303.
* @link https://httpstatuses.com/302
*/
class HttpFound extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::FOUND;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpGatewayTimeout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The server was acting as a gateway or proxy and did not receive a timely
* response from the upstream server.
* @link https://httpstatuses.com/504
*/
class HttpGatewayTimeout extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::GATEWAY_TIMEOUT;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpGone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpGone extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::GONE;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpImATeapot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpImATeapot extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::IM_A_TEAPOT;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpInsufficientStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The server is unable to store the representation needed to complete the
* request.
* @link https://httpstatuses.com/507
*/
class HttpInsufficientStorage extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::INSUFFICIENT_STORAGE;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpInternalServerError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* A generic error message, given when an unexpected condition was encountered
* and no more specific message is suitable.
* @link https://httpstatuses.com/500
*/
class HttpInternalServerError extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::INTERNAL_SERVER_ERROR;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpLengthRequired.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpLengthRequired extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::LENGTH_REQUIRED;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpLocked.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpLocked extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::LOCKED;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpLoopDetected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The server detected an infinite loop while processing the request (sent
* instead of 208 Already Reported).
* @link https://httpstatuses.com/508
*/
class HttpLoopDetected extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::LOOP_DETECTED;
}
}
16 changes: 16 additions & 0 deletions src/ResponseStatusException/HttpMethodNotAllowed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* A request method is not supported for the requested resource; for example, a
* GET request on a form that requires data to be presented via POST, or a PUT
* request on a read-only resource.
* @link https://httpstatuses.com/405
*/
class HttpMethodNotAllowed extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::METHOD_NOT_ALLOWED;
}
}
10 changes: 10 additions & 0 deletions src/ResponseStatusException/HttpMisdirectedRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

class HttpMisdirectedRequest extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::MISDIRECTED_REQUEST;
}
}
14 changes: 14 additions & 0 deletions src/ResponseStatusException/HttpMovedPermanently.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* This and all future requests should be directed to the given URI.
* @link https://httpstatuses.com/301
*/
class HttpMovedPermanently extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::MOVED_PERMANENTLY;
}
}
17 changes: 17 additions & 0 deletions src/ResponseStatusException/HttpMultipleChoices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* Indicates multiple options for the resource from which the client may choose
* (via agent-driven content negotiation). For example, this code could be used
* to present multiple video format options, to list files with different
* filename extensions, or to suggest word-sense disambiguation.
* @link https://httpstatuses.com/300
*/
class HttpMultipleChoices extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::MULTIPLE_CHOICES;
}
}
17 changes: 17 additions & 0 deletions src/ResponseStatusException/HttpNetworkAuthenticationRequired.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The client needs to authenticate to gain network access. Intended for use by
* intercepting proxies used to control access to the network (e.g., "captive
* portals" used to require agreement to Terms of Service before granting full
* Internet access via a Wi-Fi hotspot).
* @link https://httpstatuses.com/511
*/
class HttpNetworkAuthenticationRequired extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::NETWORK_AUTHENTICATION_REQUIRED;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpNotAcceptable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The requested resource is capable of generating only content not acceptable
* according to the Accept headers sent in the request.
* @linkhttps://httpstatuses.com/406
*/
class HttpNotAcceptable extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::NOT_ACCEPTABLE;
}
}
14 changes: 14 additions & 0 deletions src/ResponseStatusException/HttpNotExtended.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* Further extensions to the request are required for the server to fulfil it.
* @link https://httpstatuses.com/510
*/
class HttpNotExtended extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::NOT_EXTENDED;
}
}
15 changes: 15 additions & 0 deletions src/ResponseStatusException/HttpNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Gt\Http\ResponseStatusException;

use Gt\Http\StatusCode;

/**
* The requested resource could not be found but may be available in the future.
* Subsequent requests by the client are permissible.
* @link https://httpstatuses.com/404
*/
class HttpNotFound extends AbstractResponseStatusException {
protected function getHttpCode():int {
return StatusCode::NOT_FOUND;
}
}
Loading