Build the approval path from the given parts.

@param string[] $parts

@throws \Bitbucket\Exception\InvalidArgumentException

@return string
428488
protected function buildApprovalPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'pullrequests', $this->pr, 'approve', ...$parts);
    }
195272
protected function processParts($parts)
    {
        $num_parts = count($parts);
        $parts_etags = [];
        $parts_completed = 0;

        $max_retries = FilestackConfig::MAX_RETRIES;

        $current_part_index = 0;
        while($parts_completed < $num_parts) {
            $part = $parts[$current_part_index];
            $part['part_size'] = 0;
            $chunks = $part['chunks'];

            // process chunks of current part
            $promises = $this->processChunks($part, $chunks);

            // sends s3 chunks asyncronously
            $s3_results = $this->settlePromises($promises);
            $this->handleS3PromisesResult($s3_results);

            // handle fulfilled promises
            if ($this->intelligent) {
                // commit part
                $this->commitPart($part);
            }
            else {
                $part_num = array_key_exists('part_num', $part) ?
                    $part['part_num'] : 1;

                $this->multipartGetTags($part_num, $s3_results, $parts_etags);
            }

            unset($promises);
            unset($s3_results);

            $current_part_index++;
            $parts_completed++;
        }

        if (!$this->intelligent) {
            return implode(';', $parts_etags);
        }

        return $parts_completed;
    }
1091005
public function fromArray(array $parts)
	{	//	runs parameters through __set()
		$this->scheme	=	$parts['scheme']	??	null;
		$this->user		=	$parts['user']		??	null;
		$this->pass		=	$parts['pass']		??	null;
		$this->host		=	$parts['host']		??	null;
		$this->port		=	$parts['port']		??	null;
		$this->path		=	$parts['path']		??	null;
		$this->query	=	$parts['query']		??	null;
		$this->fragment	=	$parts['fragment']	??	null;
	}
212905
function build_url( $parts = null )
	{
		if (is_string($parts))
		{
			if ($parts === '' || $parts === '//')
				return $this->uri->withScheme(null);								//	'//' . $this->uri->authority . $this->uri->getPathAndQuery();
			if ($parts[0] === '/')
				return $this->uri->getLeftPart(Uri::PARTIAL_AUTHORITY) . $parts;	//	(_::is_https() ? 'https://' : 'http://') . _::request('host') . $parts;
			if ($parts === 'https' || $parts === 'http')
				return $this->uri->withScheme($parts);								//	$parts . '://' . _::request('host') . _::request('uri');
			if ($parts[0] === '?')
				return $this->uri->getLeftPart(Uri::PARTIAL_PATH) . $parts;			//	(_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . $parts;
			if (strpos($parts, '=') !== false)
				return $this->uri->getLeftPart(Uri::PARTIAL_PATH) . '?' . $parts;	//	(_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . '?' . $parts;
			if ($parts[0] === '#')
				return $this->uri->withFragment($parts);							//	(_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('uri') . $parts;
			throw new \Exception("Invalid call to Request::build_url('{$parts}')");
		}
		return (string) (new Uri($parts));
/*
		return	(isset($parts['scheme']) ? (empty($parts['scheme']) ? '//' : $parts['scheme'] . '://') : ($this->uri->scheme ?? 'http') : 'http://')) .	// Can set `scheme` to NULL to generate a Protocol-Relative-URL!
				'//' . (empty($parts['host']) ? $this->uri->authority : $parts['host']) .
				(empty($parts['path']) ? _::request('path') : $parts['path']) .
				(isset($parts['query']) ? (empty($parts['query']) ? null : '?' . $parts['query']) : (empty($parts['path']) && _::request('query') ? '?' . _::request('query') : null)); // NO FRAGMENT! We can append it if we really need it!
*/
	}
114511
private function applyParts(array $parts)
    {
        $this->scheme = isset($parts['scheme'])
            ? $this->filterScheme($parts['scheme'])
            : '';
        $this->userInfo = isset($parts['user']) ? $parts['user'] : '';
        $this->host = isset($parts['host']) ? $parts['host'] : '';
        $this->port = !empty($parts['port'])
            ? $this->filterPort($this->scheme, $this->host, $parts['port'])
            : null;
        $this->path = isset($parts['path'])
            ? $this->filterPath($parts['path'])
            : '';
        $this->query = isset($parts['query'])
            ? $this->filterQueryAndFragment($parts['query'])
            : '';
        $this->fragment = isset($parts['fragment'])
            ? $this->filterQueryAndFragment($parts['fragment'])
            : '';
        if (isset($parts['pass'])) {
            $this->userInfo .= ':' . $parts['pass'];
        }
    }
55480
static protected function buildUrlSchemeHostPort(&$parts)
    {
        $return = '';
        if ($parts['scheme'] == 'omit') {
            $parts['scheme'] = null;
        } elseif (!$parts['scheme'] && !$parts['host']) {
            return '';
        } elseif (!$parts['scheme']) {
            // we passed a host, but no scheme
            if (\in_array($parts['host'], array(
                    '127.0.0.1',
                    'localhost',
                    isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : null,
            ))) {
                $local = true;
            } else {
                $regex = '#(.+\.)?(\w+.[a-z])$#';
                $hostDomain = \preg_replace($regex, '$1', $parts['host']);
                $localDomain = \preg_replace($regex, '$1', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
                $local = $hostDomain == $localDomain;
            }
            if ($local) {
                $parts['scheme'] = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on'
                    ? 'https'
                    : 'http';
            } else {
                $parts['scheme'] = 'http';
            }
        } elseif (!\in_array($parts['scheme'], array('http','https'))) {
            $parts = \array_diff_key($parts, \array_flip(array('query','fragment','params')));
        }
        if ($parts['scheme']) {
            $return .= $parts['scheme'].':';
        }
        if ($parts['host']) {
            $return .= '//';
            $parts = \array_merge(array('user'=>null,'pass'=>null), $parts);
            if (!empty($parts['user'])) {
                $return .= $parts['user'].\rtrim(':'.$parts['pass'], ':').'@';
            }
            $return .= $parts['host'];
            if ($parts['port']) {
                $defaultPorts = array(
                    'http' => 80,
                    'https' => 443,
                );
                if ($parts['scheme']) {
                    if (isset($defaultPorts[ $parts['scheme'] ]) && $parts['port'] == $defaultPorts[ $parts['scheme'] ]) {
                        $parts['port'] = null;
                    }
                } elseif (in_array($parts['port'], $defaultPorts)) {
                    $parts['port'] = null;
                }
                $return .= \rtrim(':'.$parts['port'], ':');
            }
        }
        return $return;
    }
655206
protected function buildStatusesPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'commit', $this->commit, 'statuses', ...$parts);
    }
157301
private static function classRebuild($parts)
    {
        $parts['attribs']['class'] = \array_unique($parts['attribs']['class']);
        $parts['attribs']['class'] = \array_filter($parts['attribs']['class'], 'strlen');
        \sort($parts['attribs']['class']);
        if (!$parts['classIsArray']) {
            $parts['attribs']['class'] = \implode(' ', $parts['attribs']['class']);
        }
        if ($parts['aosIs'] == 'tag') {
            return self::buildTag($parts['tagname'], $parts['attribs'], $parts['innerhtml']);
        } elseif ($parts['aosIs'] == 'attribs') {
            return $parts['attribsIsArray']
                ? $parts['attribs']
                : self::buildAttribString($parts['attribs']);
        } elseif ($parts['aosIs'] == 'class') {
            return $parts['attribs']['class'];
        }
    }
1305502
protected function buildChangesPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'changes', ...$parts);
    }
1310671
private function parseParts(array $parts = [])
    {
        // Get and unset the mime type
        $mimeType = $parts[0];
        unset($parts[0]);

        // Set default quality to 1 since the HTTP/1.1 specification says that if no
        // quality is provided it defaults to 1
        $support = [ 'value' => $mimeType, 'quality' => (float) 1 ];

        // Loop through the parts
        foreach ($parts as $part) {
            // Save all params
            $param = explode('=', $part);
            // Make sure we exploded the string
            if (isset($param[1])) {
                // Save param
                if ($param[0] === 'q') {
                    $support['quality'] = (float) $param[1];
                } else {
                    $support['parameters'][$param[0]] = $param[1];
                }
            }
        }

        return $support;
    }
251741
protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1) {
        $regex = '';
        foreach ($parts as $part) {
            switch ($part[0]) {
                case 'literal':
                    $regex .= preg_quote($part[1]);
                    break;
                case 'parameter':
                    $groupName = '?P<param' . $groupIndex . '>';
                    if (isset($constraints[$part[1]])) {
                        $regex .= '(' . $groupName . $constraints[$part[1]] . ')';
                    } elseif ($part[2] === null) {
                        $regex .= '(' . $groupName . '[^/]+)';
                    } else {
                        $regex .= '(' . $groupName . '[^' . $part[2] . ']+)';
                    }
                    $this->paramMap['param' . $groupIndex++] = $part[1];
                    break;
                case 'optional':
                    $regex .= '(?:' . $this->buildRegex($part[1], $constraints, $groupIndex) . ')?';
                    break;
            }
        }
        return $regex;
    }
771180
public static function join_paths($part = null)
    {
        $args = func_get_args();
        if (count($args) === 1 && is_array($args[0])) {
            $args = $args[0];
        }

        $parts = array();
        foreach ($args as $arg) {
            $part = trim($arg, ' \\/');
            if ($part) {
                $parts[] = $part;
            }
        }

        return implode('/', $parts);
    }
1332698
protected function buildUrl( $parts )
	{
		$url	= new ADT_StringBuffer();
		if( isset( $parts['user'] ) && isset( $parts['pass'] ) && $parts['user'] )
			$url->append( $parts['user'].":".$parts['pass']."@" );
		if( substr( $parts['path'], 0, 1 ) != "/" )
			$parts['path']	= "/".$parts['path'];
		$host	= $parts['host'].( !empty( $parts['port'] ) ? ":".$parts['port'] : "" );
		$url->append( $host.$parts['path'] );
		if( isset( $parts['query'] ) )
			$url->append( "?".$parts['query'] );
		$url	= str_replace( "//", "/", $url->toString() );
		$url	= $parts['scheme']."://".$url;
		return $url;
	}
609594
public function getUrl($path, array $params = [])
    {
        $parts = parse_url($this->baseUrl.'/'.trim($path, '/'));

        if ($parts === false) {
            throw new InvalidArgumentException('Not a valid path.');
        }

        $parts['path'] = '/'.trim($parts['path'], '/');

        if ($this->signature) {
            $params = $this->signature->addSignature($parts['path'], $params);
        }

        return $this->buildUrl($parts, $params);
    }
200283
static function buildUrl($parts)
    {
        $parts = new ArrayObject($parts);

        ###################
        ### PARSE PARTS ###
        ###################

        // scheme
        $scheme = $parts->key('scheme', '', true);

        // host
        $host = $parts->key('host', '', true);

        // port
        $port = $parts->key('port', '', true);

        // path
        $path = $parts->key('path', '', true);

        // parse query string
        $query = '';
        if($parts->keyExists('query')) {
            if(self::isString($parts->key('query'))) {
                parse_str($parts->key('query'), $queryData);
            } else {
                $queryData = $parts->key('query');
            }

            if(self::isArray($queryData)) {
                $query = $queryData;
            }
        }


        ###################
        ### BUILD URL   ###
        ###################
        $url = '';

        // scheme
        if($scheme && $scheme != '') {
            $url .= $scheme . '://';
        }

        // host
        if($host && $host != '') {
            $url .= $host;
        }

        // port
        if($port != '') {
            $url .= ':' . $port;
        }

        // path
        if($path != '') {
            $url .= $path;
        }

        // query
        if(self::isArray($query)) {
            $query = http_build_query($query);
            if($query != "") {
                $url .= '?' . $query;
            }
        }

        try {
            return new UrlObject($url);
        } catch (\Exception $e) {
            throw new UrlObjectException($e->getMessage());
        }
    }
715809
public function addParts($parts): CompositeBuilder
    {
        foreach ($parts as $part) {
            $this->addPart($part);
        }

        return $this;
    }
745651
protected function buildVotingPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'vote', ...$parts);
    }