Skip to content

Commit 90db63a

Browse files
authored
Merge pull request #833 from WordPress/add/http-status-code-helper
Add HTTP status helper class
2 parents c7977fc + 451f7b0 commit 90db63a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1654
-145
lines changed

src/Exception/Http/Status304.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 304 Not Modified responses
@@ -29,5 +30,5 @@ final class Status304 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Not Modified';
33+
protected $reason = HttpStatus::TEXT_304;
3334
}

src/Exception/Http/Status305.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 305 Use Proxy responses
@@ -29,5 +30,5 @@ final class Status305 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Use Proxy';
33+
protected $reason = HttpStatus::TEXT_305;
3334
}

src/Exception/Http/Status306.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 306 Switch Proxy responses
@@ -29,5 +30,5 @@ final class Status306 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Switch Proxy';
33+
protected $reason = HttpStatus::TEXT_306;
3334
}

src/Exception/Http/Status400.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 400 Bad Request responses
@@ -29,5 +30,5 @@ final class Status400 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Bad Request';
33+
protected $reason = HttpStatus::TEXT_400;
3334
}

src/Exception/Http/Status401.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 401 Unauthorized responses
@@ -29,5 +30,5 @@ final class Status401 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Unauthorized';
33+
protected $reason = HttpStatus::TEXT_401;
3334
}

src/Exception/Http/Status402.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 402 Payment Required responses
@@ -29,5 +30,5 @@ final class Status402 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Payment Required';
33+
protected $reason = HttpStatus::TEXT_402;
3334
}

src/Exception/Http/Status403.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 403 Forbidden responses
@@ -29,5 +30,5 @@ final class Status403 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Forbidden';
33+
protected $reason = HttpStatus::TEXT_403;
3334
}

src/Exception/Http/Status404.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 404 Not Found responses
@@ -29,5 +30,5 @@ final class Status404 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Not Found';
33+
protected $reason = HttpStatus::TEXT_404;
3334
}

src/Exception/Http/Status405.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 405 Method Not Allowed responses
@@ -29,5 +30,5 @@ final class Status405 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Method Not Allowed';
33+
protected $reason = HttpStatus::TEXT_405;
3334
}

src/Exception/Http/Status406.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WpOrg\Requests\Exception\Http;
1111

1212
use WpOrg\Requests\Exception\Http;
13+
use WpOrg\Requests\Utility\HttpStatus;
1314

1415
/**
1516
* Exception for 406 Not Acceptable responses
@@ -29,5 +30,5 @@ final class Status406 extends Http {
2930
*
3031
* @var string
3132
*/
32-
protected $reason = 'Not Acceptable';
33+
protected $reason = HttpStatus::TEXT_406;
3334
}

0 commit comments

Comments
 (0)