Merge "Special:Newpages feed now shows first revision instead of latest revision"
[lhc/web/wiklou.git] / includes / config / GlobalVarConfig.php
index 0841a00..589f7d3 100644 (file)
@@ -49,14 +49,17 @@ class GlobalVarConfig implements Config {
         * @see Config::get
         */
        public function get( $name ) {
+               if ( !$this->has( $name ) ) {
+                       throw new ConfigException( __METHOD__ . ": undefined option: '$name'" );
+               }
                return $this->getWithPrefix( $this->prefix, $name );
        }
 
        /**
-        * @see Config::set
+        * @see Config::has
         */
-       public function set( $name, $value ) {
-               $this->setWithPrefix( $this->prefix, $name, $value );
+       public function has( $name ) {
+               return $this->hasWithPrefix( $this->prefix, $name );
        }
 
        /**
@@ -64,25 +67,21 @@ class GlobalVarConfig implements Config {
         *
         * @param string $prefix Prefix to use on the variable, if one.
         * @param string $name Variable name without prefix
-        * @throws ConfigException
         * @return mixed
         */
        protected function getWithPrefix( $prefix, $name ) {
-               $var = $prefix . $name;
-               if ( !array_key_exists( $var, $GLOBALS ) ) {
-                       throw new ConfigException( __METHOD__ . ": undefined variable: '$var'" );
-               }
-               return $GLOBALS[$var];
+               return $GLOBALS[$prefix . $name];
        }
 
        /**
-        * Get a variable with a given prefix, if not the defaults.
+        * Check if a variable with a given prefix is set
         *
         * @param string $prefix Prefix to use on the variable
         * @param string $name Variable name without prefix
-        * @param mixed $value Value to set
+        * @return bool
         */
-       protected function setWithPrefix( $prefix, $name, $value ) {
-               $GLOBALS[$prefix . $name] = $value;
+       protected function hasWithPrefix( $prefix, $name ) {
+               $var = $prefix . $name;
+               return array_key_exists( $var, $GLOBALS );
        }
 }