public static function extend($target, $source) 
    {
        switch($target) {
        case 'phpQueryObject':
            $targetRef = &self::$extendMethods;
            $targetRef2 = &self::$pluginsMethods;
            break;
        case 'phpQuery':
            $targetRef = &self::$extendStaticMethods;
            $targetRef2 = &self::$pluginsStaticMethods;
            break;
        default:
            throw new Exception("Unsupported \$target type");
        }
        if (is_string($source)) {
            $source = array($source => $source);
        }
        foreach($source as $method => $callback) {
            if (isset($targetRef[$method])) {
                //                throw new Exception
                self::debug("Duplicate method '{$method}', can\'t extend '{$target}'");
                continue;
            }
            if (isset($targetRef2[$method])) {
                //                throw new Exception
                self::debug(
                    "Duplicate method '{$method}' from plugin '{$targetRef2[$method]}',"
                    ." can\'t extend '{$target}'"
                );
                continue;
            }
            $targetRef[$method] = $callback;
        }
        return true;
    }