Added unsetVal() method as antithesis to setVal()
authorArthur Richards <awjrichards@users.mediawiki.org>
Wed, 29 Feb 2012 21:56:05 +0000 (21:56 +0000)
committerArthur Richards <awjrichards@users.mediawiki.org>
Wed, 29 Feb 2012 21:56:05 +0000 (21:56 +0000)
includes/WebRequest.php

index 826ee0d..facb82b 100644 (file)
@@ -379,6 +379,23 @@ class WebRequest {
                return $ret;
        }
 
+       
+       /**
+        * Unset an arbitrary value from our get/post data.
+        *
+        * @param $key String: key name to use
+        * @return Mixed: old value if one was present, null otherwise
+        */
+       public function unsetVal( $key ) {
+               if ( !isset( $this->data[$key] ) ) {
+                       $ret = null;
+               } else {
+                       $ret = $this->data[$key];
+                       unset( $this->data[$key] );
+               }
+               return $ret;
+       }
+
        /**
         * Fetch an array from the input or return $default if it's not set.
         * If source was scalar, will return an array with a single element.