Parse a given URL

@param  string $httpMethod HTTP method
@param  string $url URL
@return status
@access protected
177914
protected function parseUrl(
        /*# string */ $httpMethod,
        /*# string */ $url
    ) {
        $this->server = $_SERVER;
        $server = &$this->server;

        // set http method
        if ($httpMethod) {
            $server['REQUEST_METHOD'] = $httpMethod;
        } elseif (!isset($server['REQUEST_METHOD'])) {
            $server['REQUEST_METHOD'] = 'GET';
        }

        // parse url
        if (empty($url)) {
            $this->request = $_REQUEST;
        } else {
            $parts = (array) parse_url($url);

            // scheme
            if (isset($parts['scheme'])) {
                $scheme = strtolower($parts['scheme']);
                $server['HTTPS'] = 'https' === $scheme ? $scheme : '';
            }

            // host
            if (isset($parts['host'])) {
                $server['HTTP_HOST'] = $parts['host'];
            }

            // port
            if (isset($parts['port'])) {
                $server['SERVER_PORT'] = $parts['port'];
            }

            // fix query
            $this->fixUrlQuery($parts);

            // fix path
            $this->fixUrlPath($parts);
        }

        // normalize
        $server['PATH_INFO'] = '/' . trim($server['PATH_INFO'], '/');

        return $this;
    }
1307705
protected function parseUrl(string $url)
    {
        $url = trim($url, '/');

        // Proceed if the URL is still a valid URL
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            // Return an URL with a '/' if is just a domain
            return preg_match('/(\.(?<tld>\w*))$/m', $url)
                ? $url . '/'
                : $url;
        }

        throw new InvalidUrlException($url);
    }
26256
public function request($url, array $parameters = [], $requestMethod = 'GET')
    {
        try {
            $method = strtolower($requestMethod) === 'get' ? 'query' : 'form_params';
            $response = $this->getClient()->request($requestMethod, $url, [
                $method  => array_merge($this->getParams(), $parameters),
                'Accept' => 'application/json'
            ]);
            return json_decode($response->getBody());
        } catch (RequestException $e) {
            $this->printErrorMessage(Psr7\str($e->getResponse()), false);
        }
        return [];
    }
126406
public static function get($url, $httpHeaders = array())
    {
        //Initialize the Curl resource
        $ch = self::init($url, $httpHeaders);

        return self::processRequest($ch);
    }
1091383
public function dispatch($http_method, $url)
    {
        if ($this->dispatcher === null) {
            throw new \RuntimeException('Route dispatcher is not initialized');
        }

        $this->dispatched_http_method = $http_method;
        $this->dispatched_url = $url;
        $this->route_info = $this->dispatcher->dispatch($http_method, $url);

        return $this->route_info;
    }
974915
public function match($httpMethod, $uri)
    {
        $compiledRouter = $this->getCompiledRouter();

        return MatchResult::fromArray($compiledRouter($httpMethod, $uri));
    }
606351
public function request($url)
    {
        try {
            $resp = $this->guzzle->get($url);
            return (string) $resp->getBody();
        } catch (RequestException $e) {
            $response = $e->getResponse();
            throw new HttpException($response ? $response->getBody() : null, $e->getMessage(), $e->getCode(), $e);
        } catch (TransferException $e) {
            throw new HttpException('', $e->getMessage(), $e->getCode(), $e);
        }
    }
503771
public function parseUrl($url, array $data)
    {
        return (empty($data)) ? $url : $url . '?' . $this->parseData($data);
    }
432519
public function isCachable(string $url, string $httpMethod) : bool
    {
        return $httpMethod === ClientInterface::HTTP_GET && $this->getCache() !== null;
    }
715129
public function parse($url, $cleanup = true)
  {
    if ($this->isLocked()) {
      return $this->getObj()->parse($url, $cleanup)->setLocked();
    } else {
      return parent::parse($url, $cleanup);
    }
  }
145120
public static function get_http_response_code( $url ) {

		$curl = curl_init();
		curl_setopt_array(
			$curl,
			[
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_URL            => $url,
			]
		);
		curl_exec( $curl );
		$response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
		curl_close( $curl );

		return $response_code;
	}
442408
private function matchMethod($callbacks, $url)
    {
        // match a callback based on url pattern
        $methodData = false;
        $matchedParameters = false;

        // match method
        foreach ($callbacks as $pattern => $data) {
            if (($matchedParameters = $this->doesPatternMatch($pattern, $data, $url)) !== false) {
                $methodData = $data;
                break;
            } else if ($data['resourceNaming'] === false) {
                $matchedParameters = $this->tryMatchingOptionalParams($pattern, $data, $url);
                if ($matchedParameters) {
                    $methodData = $data;
                    break;
                }
            }
        }

        return [
            'methodData'        => $methodData,
            'matchedParameters' => $matchedParameters
        ];
    }
1317925
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
        }

        $query = [];

        if (isset($components['query'])) {
            parse_str($components['query'], $query);
        }

        return new static(
            $components['scheme'] ?? null,
            $components['host'] ?? null,
            $components['port'] ?? null,
            $components['path'] ?? '',
            $query,
            $components['fragment'] ?? null,
            $preferredFormat
        );
    }
877016
private function parseUrl($url)
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            throw new ConnectionException('Unable to parse url '. $url);
        }
        array_push($this->hosts, $parsed + ['port' => '61613', 'scheme' => 'tcp']);
    }
1125691
public function execute($httpMethod, $url, array $parameters = [])
    {
        if ($this->config instanceof Config) {
            try {
                $this->response = $this->getClient()->{$httpMethod}($this->config->getAccountNumber() . $url, [
                    'json' => $parameters,
                ]);

                return json_decode((string) $this->response->getBody());

            } catch (ClientException $e) {
                throw new Handler($e);
            }

            return;
        }

        throw new \RuntimeException('The API requires a configuration instance.');
    }
62254
public static function parseRoute($url)
    {
        $result = null;

        $parts = explode('/', trim($url, '/'));
        if (count($parts) === 1) {
            $parts[0] = $parts[0] === '' ? self::DEFAULT_CONTROLLER : $parts[0];
            $parts[1] = self::DEFAULT_ACTION;
        }

        $action                   = static::preparePart(array_pop($parts), true);
        $parts[count($parts) - 1] = static::preparePart($parts[count($parts) - 1]).'Controller';
        $controller               = '\\project\\controllers\\'.implode('\\',
                $parts);

        if ($action != '' && $controller != '') {
            $result = $controller.'::'.$action;
        }

        return $result;
    }
1036074
public function parse($url)
    {
        $this->_fixUrlForParsing($url);

        if (empty($url->path) && !isset($url->query['option'])) {
            $url->path = (get_viewer()->guest()) ? 'pages' : 'dashboard';
        }

        $segments = explode('/', trim($url->path, '/'));
        $segments = array_filter($segments);

        if (!empty($segments)) {
            $component = array_shift($segments);
            $url->query = array_merge(array('option' => 'com_'.$component), $url->query);
            $component = str_replace('com_', '', $url->query['option']);
            $query = $this->getComponentRouter($component)->parse($segments);
            $url->query = array_merge($url->query, array('option' => 'com_'.$component), $query);
        }

        return $url;
    }