@param  string $url

@return array
494990
private function parseArguments($url)
	{
		preg_match_all('~{(n:|a:|an:|w:|\*:|\?:)?([a-zA-Z0-9_]+)}~', $url, $matches);

		if (isset($matches[2]) && !empty($matches[2])) {
			return $matches[2];
		}

		return [];
	}
502252
protected function parseUrl($url = "")
    {
        $parsed = ($url) ? parse_url($url) : parse_url($this->_env['REQUEST_URI']);
        
        if (preg_match('/[a-zA-Z0-9_]+\.php/i', $parsed['path'], $matches)) {
            $parsed['path'] = preg_replace("/$matches[0]/", '/', $parsed['path']);
        }
        
        return $parsed;
    }
742301
private function getUrlOrigin($url)
    {
        return array(
            parse_url($url, PHP_URL_SCHEME),
            parse_url($url, PHP_URL_HOST),
            parse_url($url, PHP_URL_PORT),
        );
    }
1075802
public function discover(string $url) : array
    {
        $explorer = new Explorer($this->client, $this->logger);

        return $explorer->discover($url);
    }
1268460
public function parseQueryParams(string $url): array
    {
        return tap([], function (&$query) use ($url) {
            parse_str(parse_url($url, PHP_URL_QUERY) ?? '', $query);
        });
    }
152643
public function processUrl($url)
    {
        if (strpos($url, '::') !== false) {
            list($folder, $asset) = explode('::', $url, 2);
        } else {
            $folder = null;
            $asset = $url;
        }

        if (empty($asset)) {
            return false;
        }

        return array(
            'folder' => $folder,
            'asset' => $asset
        );
    }
397872
public static function fromString($url)
    {
        static $defaults = ['scheme' => null, 'host' => null,
            'path' => null, 'port' => null, 'query' => null,
            'user' => null, 'pass' => null, 'fragment' => null];

        if (false === ($parts = parse_url($url))) {
            throw new \InvalidArgumentException('Unable to parse malformed '
                . 'url: ' . $url);
        }

        $parts += $defaults;

        // Convert the query string into a Query object
        if ($parts['query'] || 0 !== strlen($parts['query'])) {
            $parts['query'] = Query::fromString($parts['query']);
        }

        return new static($parts['scheme'], $parts['host'], $parts['user'],
            $parts['pass'], $parts['port'], $parts['path'], $parts['query'],
            $parts['fragment']);
    }
864484
public function fetch($url)
    {
        $SHDObject = $this->getSHDWrapper($url);
        $urls      = $this->getPageUrls($SHDObject);
        $titles    = $this->getPageTitles($SHDObject);
        $snippets  = $this->getPageSnippets($SHDObject);
        return array('urls'     => $urls,
                     'titles'   => $titles,
                     'snippets' => $snippets);
    }
971277
protected function extractUrlVariables($url){
        $variables = array();
        $pattern = "/(\\".static::$_URL_VAR_CHARACTER.".*?[^\\/]*)/";
        if (preg_match($pattern,$url,$matches)){
            array_shift($matches);
            foreach($matches as $match){
                $variables[] = $match[0];
            }
        }
        return $variables;
    }
882834
protected function _applyPassedParams($url)
    {
        if (empty($this->_passParams)) {
            return $url;
        }

        return array_merge($url, $this->_passParams);
    }
1292627
public function getRemote($url){
		$ch = curl_init($url);
		curl_setopt_array($ch, [
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_TIMEOUT => 5,
			CURLOPT_SSL_VERIFYPEER => false,
			CURLOPT_FAILONERROR => true,
		]);
		$result = curl_exec($ch);
		if( false === $result ){
			return false;
		}
		$return = [
			'info' => curl_getinfo($ch),
			'body' => $result,
		];
		curl_close($ch);
		return $return;
	}
762800
public function insertUrl($url)
    {
        $time = time();

        $query = $this->connection->createQueryBuilder();

        $query
            ->insert($this->connection->quoteIdentifier(self::URL_TABLE))
            ->values(
                [
                    'created' => ':created',
                    'modified' => ':modified',
                    'original_url_md5' => ':original_url_md5',
                    'url' => ':url',
                ]
            )
            ->setParameter(':created', $time, PDO::PARAM_INT)
            ->setParameter(':modified', $time, PDO::PARAM_INT)
            ->setParameter(':original_url_md5', md5($url))
            ->setParameter(':url', $url)
        ;

        $query->execute();

        return $this->connection->lastInsertId(
            $this->getSequenceName(self::URL_TABLE, 'id')
        );
    }
830977
public function extractShortUrl(string $url):array {
		$urls = [$url];

		while($url = $this->extract($url)){
			$urls[] = $url;
		}

		return $urls;
	}
354041
final static function normalize(string $url):string{#{{{

    if(isset(
      $_SERVER['REQUEST_SCHEME'],
      $_SERVER['REQUEST_HOST'],
      $_SERVER['REQUEST_PORT'],
      $_SERVER['REQUEST_URI'],
      $_SERVER['SERVER_PORT']
    ) || PHP_SAPI ==='cli')
      return $url;

    $arr = parse_url($url);
    if($arr===false) return '';

    $a = [
      $arr['scheme']??$_SERVER['REQUEST_SCHEME'],
      '://',
      $arr['user']??'',
      ':',
      $arr['pass']??'',
      '@',
      $arr['host']??$_SERVER['HTTP_HOST'],
      ':',
      $arr['port']??$_SERVER['SERVER_PORT'],
      substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],'/')+1),
      $arr['path']??'',
      '?',
      $arr['query']??'',
      '#',
      $arr['fragment']??'',
    ];

    if(!in_array($a[0], ['http','https'])) return '';

    if($a[12]==='')            unset($a[11],$a[12]);
    if($a[14]==='')            unset($a[13],$a[14]);
    if($a[8]==80)              unset($a[7],$a[8]);
    if($a[4]==='')             unset($a[3],$a[4]);
    if($a[2]==='')             unset($a[2],$a[3],$a[4],$a[5]);
    if(strpos($a[10],'/')===0) unset($a[9]);

    while(strpos($a[10],'../')===0){
      $a[10] = substr($a[10],3);
      $a[9] = dirname($a[9]);
      if($a[9]!=='/') $a[9] .= '/';
    }

    while(strpos($a[10],'./')===0){
      $a[10] = substr($a[10],2);
    }

    if($a[10]==='.') unset($a[10]);

    return implode($a);
  }
953389
public static function _parse_url_query($url)
    {
        $array = parse_url($url);
        $query = $array['query'];

        $queryParts = explode('&', $query);

        $params = array();
        foreach ($queryParts as $param) {
            $item = explode('=', $param);
            $params[$item[0]] = empty($item[1]) ? '' : $item[1];
        }

        return $params;
    }
336467
public function urlToFormParameters($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        $vars = array();
        parse_str($query, $vars);
        return $this->valuesToFormParameters($vars, null);
    }
362795
protected function urlEncode($url)
    {
        $reserved = [
            ":" => '!%3A!ui',
            "/" => '!%2F!ui',
            "?" => '!%3F!ui',
            "#" => '!%23!ui',
            "[" => '!%5B!ui',
            "]" => '!%5D!ui',
            "@" => '!%40!ui',
            "!" => '!%21!ui',
            "$" => '!%24!ui',
            "&" => '!%26!ui',
            "'" => '!%27!ui',
            "(" => '!%28!ui',
            ")" => '!%29!ui',
            "*" => '!%2A!ui',
            "+" => '!%2B!ui',
            "," => '!%2C!ui',
            ";" => '!%3B!ui',
            "=" => '!%3D!ui',
            "%" => '!%25!ui'
        ];
        return preg_replace(array_values($reserved), array_keys($reserved), rawurlencode($url));
    }