follow up r76111. I had picked the wrong timedifference for the filecache.
[lhc/web/wiklou.git] / includes / WebRequest.php
index a29d76c..4cd120a 100644 (file)
  */
 class WebRequest {
        protected $data, $headers = array();
-       private $_response;
+
+       /**
+        * Lazy-init response object
+        * @var WebResponse
+        */
+       private $response;
 
        public function __construct() {
                /// @todo Fixme: this preemptive de-quoting can interfere with other web libraries
@@ -345,7 +350,20 @@ class WebRequest {
         * @return Boolean
         */
        public function getBool( $name, $default = false ) {
-               return $this->getVal( $name, $default ) ? true : false;
+               return (bool)$this->getVal( $name, $default );
+       }
+       
+       /**
+        * Fetch a boolean value from the input or return $default if not set.
+        * Unlike getBool, the string "false" will result in boolean false, which is
+        * useful when interpreting information sent from JavaScript.
+        *
+        * @param $name String
+        * @param $default Boolean
+        * @return Boolean
+        */
+       public function getFuzzyBool( $name, $default = false ) {
+               return $this->getBool( $name, $default ) && strcasecmp( $this->getVal( $name ), 'false' ) !== 0;
        }
 
        /**
@@ -647,14 +665,16 @@ class WebRequest {
        /**
         * Return a handle to WebResponse style object, for setting cookies,
         * headers and other stuff, for Request being worked on.
+        *
+        * @return WebResponse
         */
        public function response() {
                /* Lazy initialization of response object for this request */
-               if ( !is_object( $this->_response ) ) {
+               if ( !is_object( $this->response ) ) {
                        $class = ( $this instanceof FauxRequest ) ? 'FauxResponse' : 'WebResponse';
-                       $this->_response = new $class();
+                       $this->response = new $class();
                }
-               return $this->_response;
+               return $this->response;
        }
 
        /**