]> git.mxchange.org Git - core.git/commitdiff
Added isGetRequestMethod(), isHeadRequestMethod() and isPostRequestMethod().
authorRoland Haeder <roland@mxchange.org>
Sun, 5 Apr 2015 21:54:05 +0000 (23:54 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 5 Apr 2015 21:54:05 +0000 (23:54 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/interfaces/request/class_Requestable.php
inc/classes/main/request/console/class_ConsoleRequest.php
inc/classes/main/request/html/class_HtmlRequest.php

index 3693d94ad9473e0b8386134b31c19b5d6a42ccb6..5a9ef492d067c7cf0d9b5843f5c821af97f7add3 100644 (file)
@@ -77,6 +77,27 @@ interface Requestable extends FrameworkInterface {
         * @return      $cookieValue    Value of cookie or null if not found
         */
        function readCookie ($cookieName);
         * @return      $cookieValue    Value of cookie or null if not found
         */
        function readCookie ($cookieName);
+
+       /**
+        * Checks if the request method is GET.
+        *
+        * @return      $isGet  Whether the request method is GET
+        */
+       function isGetRequestMethod ();
+
+       /**
+        * Checks if the request method is HEAD.
+        *
+        * @return      $isHead         Whether the request method is HEAD
+        */
+       function isHeadRequestMethod ();
+
+       /**
+        * Checks if the request method is POST.
+        *
+        * @return      $isPost         Whether the request method is POST
+        */
+       function isPostRequestMethod ();
 }
 
 // [EOF]
 }
 
 // [EOF]
index eba7b74d48792161d65c3f59d579a4d9d9c3b39e..c5e070ed01adef8b202987309fdebd02fece899f 100644 (file)
@@ -118,6 +118,39 @@ class ConsoleRequest extends BaseRequest implements Requestable {
                // There are no cookies on console
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
                // There are no cookies on console
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
+
+       /**
+        * Checks if the request method is GET.
+        *
+        * @return      $isGet  Whether the request method is GET
+        * @throws      UnsupportedOperationException   This method should never be called
+        */
+       public function isGetRequestMethod () {
+               // Not support method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Checks if the request method is HEAD.
+        *
+        * @return      $isHead         Whether the request method is HEAD
+        * @throws      UnsupportedOperationException   This method should never be called
+        */
+       public function isHeadRequestMethod () {
+               // Not support method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Checks if the request method is POST.
+        *
+        * @return      $isPost         Whether the request method is POST
+        * @throws      UnsupportedOperationException   This method should never be called
+        */
+       public function isPostRequestMethod () {
+               // Not support method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
 }
 
 // [EOF]
 }
 
 // [EOF]
index 63ccd8267047627581c301b1dc5039be3c423ccf..e808c7109776f1b9d1557b63cac3c5132c362744 100644 (file)
@@ -49,6 +49,36 @@ class HtmlRequest extends BaseRequest implements Requestable {
                return $requestInstance;
        }
 
                return $requestInstance;
        }
 
+       /**
+        * Checks if the request method is GET.
+        *
+        * @return      $isGet  Whether the request method is GET
+        */
+       public function isGetRequestMethod () {
+               // Check it
+               return ($this->getRequestMethod() == 'GET');
+       }
+
+       /**
+        * Checks if the request method is HEAD.
+        *
+        * @return      $isHead         Whether the request method is HEAD
+        */
+       public function isHeadRequestMethod () {
+               // Check it
+               return ($this->getRequestMethod() == 'HEAD');
+       }
+
+       /**
+        * Checks if the request method is POST.
+        *
+        * @return      $isPost         Whether the request method is POST
+        */
+       public function isPostRequestMethod () {
+               // Check it
+               return ($this->getRequestMethod() == 'POST');
+       }
+
        /**
         * Prepares the HTML request data for usage by currently copying
         * $_REQUEST into a private attribute. Later on we can add more
        /**
         * Prepares the HTML request data for usage by currently copying
         * $_REQUEST into a private attribute. Later on we can add more