]> git.mxchange.org Git - friendica.git/commitdiff
Remove code parameter from HTTPException constructor
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 2 May 2019 01:24:51 +0000 (21:24 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 2 May 2019 15:26:55 +0000 (11:26 -0400)
- Remove duplicate HTTPException->httpcode class variable

24 files changed:
src/Network/HTTPException.php
src/Network/HTTPException/AcceptedException.php [new file with mode: 0644]
src/Network/HTTPException/BadGatewayException.php
src/Network/HTTPException/BadRequestException.php
src/Network/HTTPException/ConflictException.php
src/Network/HTTPException/ExpectationFailedException.php
src/Network/HTTPException/ForbiddenException.php
src/Network/HTTPException/GatewayTimeoutException.php
src/Network/HTTPException/GoneException.php
src/Network/HTTPException/ImATeapotException.php
src/Network/HTTPException/InternalServerErrorException.php
src/Network/HTTPException/LenghtRequiredException.php
src/Network/HTTPException/MethodNotAllowedException.php
src/Network/HTTPException/NoContentException.php [new file with mode: 0644]
src/Network/HTTPException/NonAcceptableException.php
src/Network/HTTPException/NotFoundException.php
src/Network/HTTPException/NotImplementedException.php
src/Network/HTTPException/OKException.php [new file with mode: 0644]
src/Network/HTTPException/PreconditionFailedException.php
src/Network/HTTPException/ServiceUnavaiableException.php
src/Network/HTTPException/TooManyRequestsException.php
src/Network/HTTPException/UnauthorizedException.php
src/Network/HTTPException/UnprocessableEntityException.php
src/Network/HTTPException/UnsupportedMediaTypeException.php

index b9bad457da13b0dbd17b45b7145abc1c12597197..89c447b71470ecd302b86ae8f2f105c42c4969b2 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Throwable exceptions to return HTTP status code
  *
- * This list of Exception has be extracted from
+ * This list of Exception has been extracted from
  * here http://racksburg.com/choosing-an-http-status-code/
  */
 
@@ -11,17 +11,17 @@ namespace Friendica\Network;
 
 use Exception;
 
-class HTTPException extends Exception
+abstract class HTTPException extends Exception
 {
-       var $httpcode = 200;
-       var $httpdesc = "";
+       public $httpdesc = '';
 
-       public function __construct($message = '', $code = 0, Exception $previous = null)
+       public function __construct($message = '', Exception $previous = null)
        {
-               if ($this->httpdesc == '') {
+               parent::__construct($message, $this->code, $previous);
+
+               if (empty($this->httpdesc)) {
                        $classname = str_replace('Exception', '', str_replace('Friendica\Network\HTTPException\\', '', get_class($this)));
                        $this->httpdesc = preg_replace("|([a-z])([A-Z])|",'$1 $2', $classname);
                }
-               parent::__construct($message, $code, $previous);
        }
 }
diff --git a/src/Network/HTTPException/AcceptedException.php b/src/Network/HTTPException/AcceptedException.php
new file mode 100644 (file)
index 0000000..b8c843e
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class AcceptedException extends HTTPException
+{
+       protected $code = 202;
+}
index 6fc80c909115ba09e19c09e6406c6fbdebff6239..c23d7e5a34d290ac6390b0b72cdf35a21de5a390 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class BadGatewayException extends HTTPException
 {
-       var $httpcode = 502;
+       protected $code = 502;
 }
index dd1dc191b81f99d0bd3a770d0b55d9fd34085051..9f25c61a8f3b5e92ab52df62c95c7cab9154aae3 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class BadRequestException extends HTTPException
 {
-       var $httpcode = 400;
+       protected $code = 400;
 }
index 1d5053c4b7e9dbcb2ebf5373de19fa016ae3aca4..5d63922c9b60836aacb5d2c9908fa0d91006d944 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class ConflictException extends HTTPException
 {
-       var $httpcode = 409;
+       protected $code = 409;
 }
index fe932a9f0a4861fe467c34c3456227c17df44f28..7c928f34fa282f2c7c27f17cbe1a571dc0cbc984 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class ExpectationFailedException extends HTTPException
 {
-       var $httpcode = 417;
+       protected $code = 417;
 }
index 66a063e137a47778099abdd1bd98e9e6b99300ce..f83fe524baf3bf9a32d56e3b29a1d48ecc03d3af 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class ForbiddenException extends HTTPException
 {
-       var $httpcode = 403;
-}
\ No newline at end of file
+       protected $code = 403;
+}
index bcd98080eda8e82113e007058f0a45985c38de87..2e516485064454917c05f30b501373a85c8fc58c 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class GatewayTimeoutException extends HTTPException
 {
-       var $httpcode = 504;
+       protected $code = 504;
 }
index 42e19e89da6e50933f2ce8832e8b50c603047a52..0f665206f9bd52fb6698c9a0e4e90cf9531bb9ec 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class GoneException extends HTTPException
 {
-       var $httpcode = 410;
+       protected $code = 410;
 }
index f4eea4077c7b710fa9e34f3e46c0d945bd417d85..89a28bebd89f4c9dbf841a644e34f192a99eaf8a 100644 (file)
@@ -6,6 +6,6 @@ use Friendica\Network\HTTPException;
 
 class ImATeapotException extends HTTPException
 {
-       var $httpcode = 418;
+       protected $code = 418;
        var $httpdesc = "I'm A Teapot";
 }
index c049ef25bacbfbf40b484acd946bdc35ed051e2d..dca1894fb4121263cc78a8408020dbd7febadaa6 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class InternalServerErrorException extends HTTPException
 {
-       var $httpcode = 500;
+       protected $code = 500;
 }
index 1f2f0f16bcb748eaef98f33a096d6bfca7fbd206..071cac73d08bc7c5f9d3e654c2a374d6f61735c6 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class LenghtRequiredException extends HTTPException
 {
-       var $httpcode = 411;
+       protected $code = 411;
 }
index 82fd3e786bd1f1695efa561c33de823be3355a92..128b9dc062cc1980bac994640552e99da6e072e1 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class MethodNotAllowedException extends HTTPException
 {
-       var $httpcode = 405;
+       protected $code = 405;
 }
diff --git a/src/Network/HTTPException/NoContentException.php b/src/Network/HTTPException/NoContentException.php
new file mode 100644 (file)
index 0000000..7bd60fb
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class NoContentException extends HTTPException
+{
+       protected $code = 204;
+}
index 356bc0c545a157ab50d36ca624c9d02d31f1c335..9ef40d60b6b21bad9d387f80a62ea5b1535ff4f5 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class NonAcceptableException extends HTTPException
 {
-       var $httpcode = 406;
+       protected $code = 406;
 }
index 2d24ccef044736e724c4f158555674dcf6c03bec..f581794796fe46f6f2ed855b36a537b488e37958 100644 (file)
@@ -4,6 +4,7 @@ namespace Friendica\Network\HTTPException;
 
 use Friendica\Network\HTTPException;
 
-class NotFoundException extends HTTPException {
-       var $httpcode = 404;
+class NotFoundException extends HTTPException
+{
+       protected $code = 404;
 }
index c0dc21c15860404a02e9cbdfbd724cbf6578b122..76cb5d42065defb003b515d320471121db1db183 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class NotImplementedException extends HTTPException
 {
-       var $httpcode = 501;
+       protected $code = 501;
 }
diff --git a/src/Network/HTTPException/OKException.php b/src/Network/HTTPException/OKException.php
new file mode 100644 (file)
index 0000000..d506ddf
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace Friendica\Network\HTTPException;
+
+use Friendica\Network\HTTPException;
+
+class OKException extends HTTPException
+{
+       protected $code = 200;
+}
index fd5fdbc995a072aeecd841a0f9b4095f40eed29b..325c88aa4706b402b98dc2bbde07c7b3e1e082b0 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class PreconditionFailedException extends HTTPException
 {
-       var $httpcode = 412;
+       protected $code = 412;
 }
index 9270bc4505b6dbee4d7ec08e291107b974465772..6c0e6595d849f6aba5ab55490867289dcd41e1ab 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class ServiceUnavaiableException extends HTTPException
 {
-       var $httpcode = 503;
+       protected $code = 503;
 }
index 093911f932917aefe9dfd9923ac5850c149ad1f3..e06d9d9cbf00a581779287f2af032d7392f10ec3 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class TooManyRequestsException extends HTTPException
 {
-       var $httpcode = 429;
+       protected $code = 429;
 }
index a3015d412da0648e32dccdcf5bd905288582914d..eda1f071bc5d4f4677dd7e88eeb2d474c70b0b8f 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class UnauthorizedException extends HTTPException
 {
-       var $httpcode = 401;
+       protected $code = 401;
 }
index 02852e2f929e4e821a8a5a769c74c59a7b12be6d..b33a75f7932051a2ca7ca0fb193484d7789a22c0 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class UnprocessableEntityException extends HTTPException
 {
-       var $httpcode = 422;
+       protected $code = 422;
 }
index b0399017392cf00e1d43bc7e3392d1e726eea64e..02962dfc29a72bd04ee03d756d125f7a44fcc270 100644 (file)
@@ -6,5 +6,5 @@ use Friendica\Network\HTTPException;
 
 class UnsupportedMediaTypeException extends HTTPException
 {
-       var $httpcode = 415;
+       protected $code = 415;
 }