prefix = $prefix; } /** * @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::has */ public function has( $name ) { return $this->hasWithPrefix( $this->prefix, $name ); } /** * Get a variable with a given prefix, if not the defaults. * * @param string $prefix Prefix to use on the variable, if one. * @param string $name Variable name without prefix * @return mixed */ protected function getWithPrefix( $prefix, $name ) { return $GLOBALS[$prefix . $name]; } /** * 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 * @return bool */ protected function hasWithPrefix( $prefix, $name ) { $var = $prefix . $name; return array_key_exists( $var, $GLOBALS ); } }