Build the comments path from the given parts.

@param string[] $parts

@throws \Bitbucket\Exception\InvalidArgumentException

@return string
552741
protected function buildCommentsPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'pullrequests', $this->pr, 'comments', ...$parts);
    }
231983
public function setParts(array $parts): self
    {
        $this->parts = [];
        foreach ($parts as $part) {
            $this->addPart($part);
        }

        return $this;
    }
465512
public static function create(array $parts)
    {
        if (0 === \count($parts)) {
            throw new CrunzException('At least one part expected.');
        }

        $normalizedPath = \str_replace(
            DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
            DIRECTORY_SEPARATOR,
            \implode(DIRECTORY_SEPARATOR, $parts)
        );

        return new self($normalizedPath);
    }
497560
protected function normalizeParts(array $parts)
    {
        $blockSize = $this->getPartSize();
        $callback  = function ($value) {
            return Util::safeStrlen($value);
        };
        $maxSize = max(array_map($callback, $parts));
        if ($maxSize % $blockSize != 0) {
            $maxSize += $blockSize - ($maxSize % $blockSize);
        }
        foreach ($parts as &$part) {
            $part = $this->str_pad($part, $maxSize, chr(0));
            $part = str_split($part, $blockSize);
        }

        return $parts;
    }
641044
public function to(string ...$pathParts): string
    {
        return $this->rootpath . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $pathParts);
    }
953297
public static function pathSub($path, $part, $separator = DIRECTORY_SEPARATOR)
    {
        if (empty($path)) {
            throw new ArgumentNullException("path");
        }

        if (empty($part)) {
            throw new ArgumentNullException("part");
        }

        $pattern = '@[/\\\\]+@';
        $path = preg_replace($pattern, DIRECTORY_SEPARATOR, $path);
        $part = preg_replace($pattern, DIRECTORY_SEPARATOR, $part.DIRECTORY_SEPARATOR);
        $part = preg_quote($part, '@');
        $result = preg_replace('@^'.$part.'@', DIRECTORY_SEPARATOR, $path);
        if ($separator != DIRECTORY_SEPARATOR) {
            $result = str_replace(DIRECTORY_SEPARATOR, $separator, $result);
        }

        return $result;
    }
813681
public static function assembleUrl ($parts) {
    $url = '';
    if (isset($parts['scheme'])) {
      $url .= "{$parts['scheme']}:";
    }
    $url .= '//';
    if (isset($parts['user'])) {
      $url .= $parts['user'];
      if (isset($parts['password'])) {
        $url .= ":{$parts['password']}";
      }
      $url .= '@';
    }
    if (isset($parts['host'])) {
      $url .= $parts['host'];
    }
    if (isset($parts['port'])) {
      $url .= ":{$parts['port']}";
    }
    if (isset($parts['path'])) {
      $url .= $parts['path'];
    }
    if (isset($parts['query'])) {
      $url .= "?{$parts['query']}";
    }
    if (isset($parts['fragment'])) {
      $url .= "#{$parts['fragment']}";
    }
    return $url;
  }
696932
public static function joinPaths(...$parts)
    {
        $combined = null;
        $parts = array_filter($parts);
        array_walk_recursive($parts, function ($part) use (&$combined) {
            // Normalise path
            $part = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $part);
            $combined = $combined
                ? (rtrim($combined, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $part)
                : $part;
        });
        return $combined;
    }
549373
protected function buildPath(array $parts, array $params, $optional = false) {
        $path = '';
        foreach ($parts as $part) {
            switch ($part[0]) {
                case 'literal':
                    $path .= $part[1];
                    break;
                case 'parameter':
                    if (!isset($params[$part[1]])) {
                        if (!$optional) {
                            throw new Exception(
                                __('Missing parameter "{name}"', [
                                    'name' => $path[1]
                                ])
                            );
                        }
                        return '';
                    }
                    $path .= rawurlencode($params[$part[1]]);
                    break;
                case 'optional':
                    $segment = $this->buildPath($part[1], $params, true);
                    if ($segment !== '') {
                        $path .= $segment;
                    }
                    break;
            }
        }
        return $path;
    }
965092
protected function buildPatchesPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, $this->repo, 'patch', ...$parts);
    }
589172
protected function getMemoryKey($parts=null)
	{
		return $this->memorySessionPrefix . implode('-', $parts !== null ? $parts : $this->getCurrentMemoryPath());
	}
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;
    }
1152787
private function fromCompactSerializationSignatureToSerialization(array $parts)
    {
        $temp = [];

        if (!empty($parts[1])) {
            $temp['payload'] = $parts[1];
        }
        $temp['signatures'] = [[
            'protected' => $parts[0],
            'signature' => $parts[2],
        ]];

        $this->log(LogLevel::INFO, 'JWS in Compact JSON Serialization mode loaded.');

        return $temp;
    }
958122
private function fromCompactSerializationSignatureToSerialization(array $parts)
    {
        $temp = [];

        if (!empty($parts[1])) {
            $temp['payload'] = $parts[1];
        }
        $temp['signatures'] = [[
            'protected' => $parts[0],
            'signature' => $parts[2],
        ]];

        return $temp;
    }
454760
public static function buildUrl($parts)
    {
        $url = '';

        if (isset($parts['scheme'])) {
            $url .= $parts['scheme'].'://';
        }

        if (isset($parts['user'])) {
            if (isset($parts['pass'])) {
                $url .= $parts['user'].':'.$parts['pass'].'@';
            } else {
                $url .= $parts['user'].'@';
            }
        }

        if (isset($parts['host'])) {
            $url .= $parts['host'];
        }

        if (isset($parts['port'])) {
            $url .= ':'.$parts['port'];
        }

        if (isset($parts['path'])) {
            $url .= $parts['path'];
        }

        if (isset($parts['query'])) {
            $url .= '?'.$parts['query'];
        }

        if (isset($parts['fragment'])) {
            $url .= '#'.$parts['fragment'];
        }

        return $url;
    }
228710
public function concatenate(array $parts): string
    {
        $first = \array_shift($parts);

        return \array_reduce($parts, function (string $initial, string $next): string {
            return \rtrim($initial, \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . \ltrim($next, \DIRECTORY_SEPARATOR);
        }, $first);
    }
1096644
protected function buildJsonPath(array $segments): string
	{
		$path = '';

		foreach($segments as $segment)
		{
			if(is_numeric($segment))
			{
				$path .= '[' . $segment . ']';
			}
			else
			{
				$path .= '.' . '"' . str_replace(['"', "'"], ['\\\"', "''"], $segment) . '"';
			}
		}

		return '$' . $path;
	}