Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP status helper class #833

Merged
merged 3 commits into from
Feb 12, 2024
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
3 changes: 2 additions & 1 deletion src/Exception/Http/Status304.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 304 Not Modified responses
Expand All @@ -29,5 +30,5 @@ final class Status304 extends Http {
*
* @var string
*/
protected $reason = 'Not Modified';
protected $reason = HttpStatus::TEXT_304;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status305.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 305 Use Proxy responses
Expand All @@ -29,5 +30,5 @@ final class Status305 extends Http {
*
* @var string
*/
protected $reason = 'Use Proxy';
protected $reason = HttpStatus::TEXT_305;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status306.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 306 Switch Proxy responses
Expand All @@ -29,5 +30,5 @@ final class Status306 extends Http {
*
* @var string
*/
protected $reason = 'Switch Proxy';
protected $reason = HttpStatus::TEXT_306;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status400.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 400 Bad Request responses
Expand All @@ -29,5 +30,5 @@ final class Status400 extends Http {
*
* @var string
*/
protected $reason = 'Bad Request';
protected $reason = HttpStatus::TEXT_400;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status401.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 401 Unauthorized responses
Expand All @@ -29,5 +30,5 @@ final class Status401 extends Http {
*
* @var string
*/
protected $reason = 'Unauthorized';
protected $reason = HttpStatus::TEXT_401;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status402.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 402 Payment Required responses
Expand All @@ -29,5 +30,5 @@ final class Status402 extends Http {
*
* @var string
*/
protected $reason = 'Payment Required';
protected $reason = HttpStatus::TEXT_402;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status403.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 403 Forbidden responses
Expand All @@ -29,5 +30,5 @@ final class Status403 extends Http {
*
* @var string
*/
protected $reason = 'Forbidden';
protected $reason = HttpStatus::TEXT_403;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status404.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 404 Not Found responses
Expand All @@ -29,5 +30,5 @@ final class Status404 extends Http {
*
* @var string
*/
protected $reason = 'Not Found';
protected $reason = HttpStatus::TEXT_404;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status405.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 405 Method Not Allowed responses
Expand All @@ -29,5 +30,5 @@ final class Status405 extends Http {
*
* @var string
*/
protected $reason = 'Method Not Allowed';
protected $reason = HttpStatus::TEXT_405;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status406.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 406 Not Acceptable responses
Expand All @@ -29,5 +30,5 @@ final class Status406 extends Http {
*
* @var string
*/
protected $reason = 'Not Acceptable';
protected $reason = HttpStatus::TEXT_406;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status407.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 407 Proxy Authentication Required responses
Expand All @@ -29,5 +30,5 @@ final class Status407 extends Http {
*
* @var string
*/
protected $reason = 'Proxy Authentication Required';
protected $reason = HttpStatus::TEXT_407;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status408.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 408 Request Timeout responses
Expand All @@ -29,5 +30,5 @@ final class Status408 extends Http {
*
* @var string
*/
protected $reason = 'Request Timeout';
protected $reason = HttpStatus::TEXT_408;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status409.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 409 Conflict responses
Expand All @@ -29,5 +30,5 @@ final class Status409 extends Http {
*
* @var string
*/
protected $reason = 'Conflict';
protected $reason = HttpStatus::TEXT_409;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status410.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 410 Gone responses
Expand All @@ -29,5 +30,5 @@ final class Status410 extends Http {
*
* @var string
*/
protected $reason = 'Gone';
protected $reason = HttpStatus::TEXT_410;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status411.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 411 Length Required responses
Expand All @@ -29,5 +30,5 @@ final class Status411 extends Http {
*
* @var string
*/
protected $reason = 'Length Required';
protected $reason = HttpStatus::TEXT_411;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status412.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 412 Precondition Failed responses
Expand All @@ -29,5 +30,5 @@ final class Status412 extends Http {
*
* @var string
*/
protected $reason = 'Precondition Failed';
protected $reason = HttpStatus::TEXT_412;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status413.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 413 Request Entity Too Large responses
Expand All @@ -29,5 +30,5 @@ final class Status413 extends Http {
*
* @var string
*/
protected $reason = 'Request Entity Too Large';
protected $reason = HttpStatus::TEXT_413;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status414.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 414 Request-URI Too Large responses
Expand All @@ -29,5 +30,5 @@ final class Status414 extends Http {
*
* @var string
*/
protected $reason = 'Request-URI Too Large';
protected $reason = HttpStatus::TEXT_414;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status415.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 415 Unsupported Media Type responses
Expand All @@ -29,5 +30,5 @@ final class Status415 extends Http {
*
* @var string
*/
protected $reason = 'Unsupported Media Type';
protected $reason = HttpStatus::TEXT_415;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status416.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 416 Requested Range Not Satisfiable responses
Expand All @@ -29,5 +30,5 @@ final class Status416 extends Http {
*
* @var string
*/
protected $reason = 'Requested Range Not Satisfiable';
protected $reason = HttpStatus::TEXT_416;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status417.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 417 Expectation Failed responses
Expand All @@ -29,5 +30,5 @@ final class Status417 extends Http {
*
* @var string
*/
protected $reason = 'Expectation Failed';
protected $reason = HttpStatus::TEXT_417;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status418.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 418 I'm A Teapot responses
Expand All @@ -31,5 +32,5 @@ final class Status418 extends Http {
*
* @var string
*/
protected $reason = "I'm A Teapot";
protected $reason = HttpStatus::TEXT_418;
}
34 changes: 34 additions & 0 deletions src/Exception/Http/Status421.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Requests for PHP, an HTTP library.
*
* @copyright 2012-2023 Requests Contributors
* @license https://github.com/WordPress/Requests/blob/stable/LICENSE ISC
* @link https://github.com/WordPress/Requests
*/

namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 421 Misdirected Request responses
*
* @package Requests\Exceptions
*/
final class Status421 extends Http {
/**
* HTTP status code
*
* @var int
*/
protected $code = 421;

/**
* Reason phrase
*
* @var string
*/
protected $reason = HttpStatus::TEXT_421;
}
34 changes: 34 additions & 0 deletions src/Exception/Http/Status422.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Requests for PHP, an HTTP library.
*
* @copyright 2012-2023 Requests Contributors
* @license https://github.com/WordPress/Requests/blob/stable/LICENSE ISC
* @link https://github.com/WordPress/Requests
*/

namespace WpOrg\Requests\Exception\Http;

use WpOrg\Requests\Exception\Http;
use WpOrg\Requests\Utility\HttpStatus;

/**
* Exception for 422 Unprocessable Content responses
*
* @package Requests\Exceptions
*/
final class Status422 extends Http {
/**
* HTTP status code
*
* @var int
*/
protected $code = 422;

/**
* Reason phrase
*
* @var string
*/
protected $reason = HttpStatus::TEXT_422;
}
Loading
Loading