Skip to content

Commit

Permalink
Use new HttpStatus utility class in exceptions and TransportMock
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Oct 9, 2023
1 parent cca92a9 commit 184208a
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 83 deletions.
3 changes: 2 additions & 1 deletion src/Exception/Http/Status304.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 304 Not Modified responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 305 Use Proxy responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 306 Switch Proxy responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 400 Bad Request responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 401 Unauthorized responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 402 Payment Required responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 403 Forbidden responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 404 Not Found responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 406 Not Acceptable responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 408 Request Timeout responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 409 Conflict responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 410 Gone responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 411 Length Required responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 412 Precondition Failed responses
Expand All @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,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 @@ -27,5 +28,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 @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 417 Expectation Failed responses
Expand All @@ -27,5 +28,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;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status428.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 428 Precondition Required responses
Expand All @@ -31,5 +32,5 @@ final class Status428 extends Http {
*
* @var string
*/
protected $reason = 'Precondition Required';
protected $reason = HttpStatus::TEXT_428;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status429.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 429 Too Many Requests responses
Expand All @@ -31,5 +32,5 @@ final class Status429 extends Http {
*
* @var string
*/
protected $reason = 'Too Many Requests';
protected $reason = HttpStatus::TEXT_429;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status431.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 431 Request Header Fields Too Large responses
Expand All @@ -31,5 +32,5 @@ final class Status431 extends Http {
*
* @var string
*/
protected $reason = 'Request Header Fields Too Large';
protected $reason = HttpStatus::TEXT_431;
}
3 changes: 2 additions & 1 deletion src/Exception/Http/Status500.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace WpOrg\Requests\Exception\Http;

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

/**
* Exception for 500 Internal Server Error responses
Expand All @@ -27,5 +28,5 @@ final class Status500 extends Http {
*
* @var string
*/
protected $reason = 'Internal Server Error';
protected $reason = HttpStatus::TEXT_500;
}
Loading

0 comments on commit 184208a

Please sign in to comment.