Code sync from ship-simu code (all class config entries must end with _class!)
[mailer.git] / inc / classes / main / request / class_HttpRequest.php
index e3bb312f9ea3757b0cb0d4dbd7b70a187a567c30..b6f9b95f46c6f2cd874228c1b2afde5532df8f1c 100644 (file)
@@ -93,7 +93,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
                if (!isset($this->requestData[$element])) {
                        // Then throw an exception
                        throw new MissingArrayElementsException(array($this, 'requestData', $element), self::EXCEPTION_MISSING_ELEMENT);
-               }
+               } // END - if
 
                // All clear
                return true;
@@ -113,7 +113,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
                try {
                        if ($this->isRequestElementSet($element)) {
                                $value = $this->requestData[$element];
-                       }
+                       } // END - if
                } catch (MissingArrayElementsException $e) {
                        // Do nothing here
                }
@@ -158,7 +158,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
                // Does this header exist?
                if (isset($_SERVER[$name])) {
                        $headerValue = $_SERVER[$name];
-               }
+               } // END - if
 
                // Return the value
                return $headerValue;
@@ -176,7 +176,7 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
        /**
         * Sets wether the request was valid (default: true)
         *
-        * @param       $isValid                Wether the request is valid
+        * @param       $isValid        Wether the request is valid
         * @return      void
         */
        public final function requestIsValid ($isValid = true) {
@@ -191,6 +191,26 @@ class HttpRequest extends BaseFrameworkSystem implements Requestable {
        public final function isRequestValid () {
                return $this->requestIsValid;
        }
+
+       /**
+        * Reads a cookie and returns it's value or null if not found
+        *
+        * @param       $cookieName             Name of cookie we shall read
+        * @return      $cookieValue    Value of cookie or null if not found
+        */
+       public final function readCookie ($cookieName) {
+               // Default is no cookie with that name found
+               $cookieValue = null;
+
+               // Is the cookie set?
+               if (isset($_COOKIE[$cookieName])) {
+                       // Then get it
+                       $cookieValue = $_COOKIE[$cookieName];
+               } // END - if
+
+               // Return the value
+               return $cookieValue;
+       }
 }
 
 // [EOF]