Build the watching path from the given parts.

@param string[] $parts

@throws \Bitbucket\Exception\InvalidArgumentException

@return string
344392
protected function buildWatchingPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'watch', ...$parts);
    }
595687
public static function combine(?string ...$parts) : ?string
    {
        if (empty($parts)) {
            return null;
        }

        $key = hash('crc32', json_encode($parts));

        if (isset(self::$cache[$key])) {
            return self::$cache[$key];
        }

        $maxIndex = count($parts) - 1;
        $path = [];

        foreach ($parts as $index => $part) {
            if ($part !== '0' && empty($part)) {
                continue;
            }

            $part = str_replace('\\', '/', $part);

            if ($index === 0) {
                $path[] = rtrim($part, '/');
            } elseif ($index === $maxIndex) {
                $path[] = ltrim($part, '/');
            } else {
                $path[] = trim($part, '/');
            }
        }

        if (empty($path)) {
            return null;
        }

        $fullPath = implode('/', $path);

        if (is_dir($fullPath) || is_file($fullPath)) {
            return realpath($fullPath);
        }

        return self::$cache[$key] = $fullPath;
    }
453795
protected function processParts(array $parts)
    {
        $combined = new ArrayObject();
        $splitParts = new ArrayObject();
        $strCat = '';
        $strName = '';
        $parts[] = $this->partFactory->newToken(';');
        foreach ($parts as $part) {
            $pValue = $part->getValue();
            if ($part instanceof Token && $this->processTokenPart($pValue, $combined, $splitParts, $strName, $strCat)) {
                continue;
            }
            $strCat .= $pValue;
        }
        return $this->finalizeParameterParts($combined);
    }
1161024
protected function buildCommentsPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'comments', ...$parts);
    }
440345
public function getUrl($parts = self::FULL)
    {
        $url = '';

        //Add the scheme
        if (($parts & self::SCHEME) && !empty($this->scheme)) {
            $url .=  urlencode($this->scheme).'://';
        }

        //Add the username and password
        if (($parts & self::USER) && !empty($this->user)) {
            $url .= urlencode($this->user);
            if (($parts & self::PASS) && !empty($this->pass)) {
                $url .= ':' . urlencode($this->pass);
            }

            $url .= '@';
        }

        // Add the host and port, if any.
        if (($parts & self::HOST) && !empty($this->host)) {
            $url .=  urlencode($this->host);

            if (($parts & self::PORT) && !empty($this->port)) {
                $url .=  ':' . (int) $this->port;
            }
        }

        // Add the rest of the url. we use trim() instead of empty() on string
        // elements to allow for string-zero values.
        if (($parts & self::PATH) && !empty($this->path)) {
            $url .= $this->_pathEncode($this->path);
            if (($parts & self::FORMAT) && trim($this->format) !== '') {
                $url .= '.' . urlencode($this->format);
            }
        }

        $query = $this->getQuery();
        
        if (($parts & self::QUERY) && !empty($query)) {
            $url .= '?' . $this->getQuery();
        }

        if (($parts & self::FRAGMENT) && trim($this->fragment) !== '') {
            $url .=  '#' . urlencode($this->fragment);
        }

        return $url;
    }
965092
protected function buildPatchesPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, $this->repo, 'patch', ...$parts);
    }
745651
protected function buildVotingPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'vote', ...$parts);
    }
428488
protected function buildApprovalPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'pullrequests', $this->pr, 'approve', ...$parts);
    }
514800
public function with(array $parts)
    {
        foreach ($parts as $key => $part)
        {
            $this->with[$key] = $part;
        }

        return $this;
    }
1101831
protected function skipIgnoredParts(array $parts): int
    {
        $k = count($parts);

        while (--$k >= 0) {
            if (!$this->isIgnoredPart($parts[$k])) {
                break;
            }
        }

        return $k;
    }
81738
protected function buildCommentsPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'commit', $this->commit, 'comments', ...$parts);
    }
698676
public static function buildUrl($baseUrl, array $parts = [])
    {
        $url = $baseUrl;

        foreach ($parts as $part) {
            if (strpos($part, '/') !== false) {
                @list(,$part) = explode('/', $part);
            }

            $url .= '/' . urlencode($part);
        }

        return $url;
    }
1168702
final public function createTraitFromStringArray(array $parts) : Trait_
    {
        return new Trait_(
            $this->extractClazzPart($parts),
            new Namespaze($this->extractNamespaceParts($parts))
        );
    }
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;
    }
676199
protected function _path($id, $parts = false)
    {
        $partsArray = array();
        $root = $this->_options['cache_dir'];
        $prefix = $this->_options['file_name_prefix'];
        if ($this->_options['hashed_directory_level']>0) {
            $hash = hash('adler32', $id);
            for ($i=0 ; $i < $this->_options['hashed_directory_level'] ; $i++) {
                $root = $root . $prefix . '--' . substr($hash, 0, $i + 1) . DIRECTORY_SEPARATOR;
                $partsArray[] = $root;
            }
        }
        if ($parts) {
            return $partsArray;
        } else {
            return $root;
        }
    }
326889
protected function buildUri(array $parts)
    {
        $uri = 
            ($parts['scheme'] ? "{$parts['scheme']}:" : '') . 
            ($parts['user'] || $parts['host'] ? '//' : '') . 
            ($parts['user'] ? "{$parts['user']}" : '') . 
            ($parts['user'] && $parts['pass'] ? ":{$parts['pass']}" : '') . 
            ($parts['user'] ? '@' : '') . 
            ($parts['host'] ? "{$parts['host']}" : '') . 
            ($parts['port'] ? ":{$parts['port']}" : '');
            
        $uri .=
            ($uri && $parts['path'] && $parts['path'][0] !== '/' ? '/' : '') .
            ($parts['path'] ? "{$parts['path']}" : '') . 
            ($parts['query'] ? "?{$parts['query']}" : '') . 
            ($parts['fragment'] ? "#{$parts['fragment']}" : '');
            
        return $uri;
    }
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;
    }