Url::appendPathSegment()

@return
511035
public function appendPathSegment($segment)
    {
        if (substr($this->path, -1) != static::PATH_SEGMENT_SEPARATOR) $this->path .= static::PATH_SEGMENT_SEPARATOR;
        if (substr($segment, 0, 1) == static::PATH_SEGMENT_SEPARATOR) $segment = substr($segment, 1);
        $this->path .= $segment;
        return $this;
    }
1266887
public function appendUrlPath($urlPath)
    {
        Validate::isString($urlPath, 'urlPath');

        $newUrlPath = parse_url($this->_url, PHP_URL_PATH).$urlPath;
        $this->_url->setPath($newUrlPath);
    }
681866
public function asEmbedPath()
    {
        $parent_entity = $this->getParent();
        if (!$parent_entity) {
            return '';
        }

        $path_parts = [];
        $current_entity = $this;
        while ($parent_entity) {
            $parent_attr_name = $current_entity->getType()->getParentAttribute()->getName();
            $path_parts[] = sprintf(
                '%s[%d]',
                $current_entity->getType()->getPrefix(),
                $parent_entity->getValue($parent_attr_name)->getKey($current_entity)
            );
            $path_parts[] = $parent_attr_name;
            if (!$parent_entity->getType()->isRoot()) {
                $path_parts[] = $parent_entity->getType()->getPrefix();
            }
            $current_entity = $parent_entity;
            $parent_entity = $parent_entity->getParent();
        }

        return implode('.', array_reverse($path_parts));
    }
151612
public function appendToUploadPath($appendedPath)
    {
        $this->uploadTo = trim($this->uploadTo, '/').'/'.trim($appendedPath, '/').'/';

        return $this;
    }
1144274
B append(BasePath<B> path) {
    ImmutableList.Builder<String> components = ImmutableList.builder();
    components.addAll(this.getSegments());
    components.addAll(path.getSegments());
    return createPathWithSegments(components.build());
  }
983430
B append(String path) {
    Preconditions.checkArgument(
        path != null && !path.isEmpty(), "'path' must be a non-empty String");
    ImmutableList.Builder<String> components = ImmutableList.builder();
    components.addAll(this.getSegments());
    components.add(splitChildPath(path));
    return createPathWithSegments(components.build());
  }
1273127
final protected function buildUrl($fragments)
    {
        // Verify url path
        if (!isset($fragments[0])) {
            throw new InvalidFragmentsParameter('Invalid base url structure, http:// path must exists at position [0]', 1);
        }

        // Cleaning up
        $url = $fragments[0];
        unset($fragments[0]);

        // Begin process for make replacements
        if (isset($fragments[1]) && is_array($fragments[1])) {
            $replacements = [];
            $params = $fragments[1];

            // Add { } to each element of the array
            array_walk($params, function (&$item, $key) use (&$replacements) {
                $replacements['{'.$key.'}'] = $item;
            });
        }

        return str_replace(array_keys($replacements), array_values($replacements), $url);
    }
660268
protected function createPathSegmentForObject($object)
    {
        $matches = [];
        preg_match_all('/(?P<dynamic>{?)(?P<content>[^}{]+)}?/', $this->getUriPattern(), $matches, PREG_SET_ORDER);
        $pathSegment = '';
        foreach ($matches as $match) {
            if (empty($match['dynamic'])) {
                $pathSegment .= $match['content'];
            } else {
                $dynamicPathSegmentParts = explode(':', $match['content']);
                $propertyPath = $dynamicPathSegmentParts[0];
                $dynamicPathSegment = ObjectAccess::getPropertyPath($object, $propertyPath);
                if (is_object($dynamicPathSegment)) {
                    if ($dynamicPathSegment instanceof \DateTimeInterface) {
                        $dateFormat = isset($dynamicPathSegmentParts[1]) ? trim($dynamicPathSegmentParts[1]) : 'Y-m-d';
                        $pathSegment .= $this->rewriteForUri($dynamicPathSegment->format($dateFormat));
                    } else {
                        throw new InvalidUriPatternException(sprintf('Invalid uriPattern "%s" for route part "%s". Property "%s" must be of type string or \DateTime. "%s" given.', $this->getUriPattern(), $this->getName(), $propertyPath, is_object($dynamicPathSegment) ? get_class($dynamicPathSegment) : gettype($dynamicPathSegment)), 1316442409);
                    }
                } else {
                    $pathSegment .= $this->rewriteForUri($dynamicPathSegment);
                }
            }
        }
        return $pathSegment;
    }
1275111
public static function removeDotSegments($path)
    {
        static $noopPaths = ['' => true, '/' => true, '*' => true];
        static $ignoreSegments = ['.' => true, '..' => true];

        if (array_key_exists($path, $noopPaths)) {
            return $path;
        }

        $results = [];
        $segments = explode('/', $path);
        foreach ($segments as $segment) {
            if ($segment === '..') {
                array_pop($results);
            } elseif (!array_key_exists($segment, $ignoreSegments)) {
                $results[] = $segment;
            }
        }

        $newPath = implode('/', $results);
        // add the leading slash if necessary
        if (strpos($path, '/') === 0 && strpos($newPath, '/') !== 0) {
            $newPath = '/' . $newPath;
        }

        // add the trailing slash if necessary
        if ($newPath !== '/' && array_key_exists(end($segments), $ignoreSegments)) {
            $newPath .= '/';
        }

        return $newPath;
    }
1199880
public function generateURLSegment()
    {
        $filter = URLSegmentFilter::create();
        $name = $this->owner->FirstName . ' ' . $this->owner->Surname;
        $urlSegment = $filter->filter($name);

        if (!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') {
            $urlSegment = 'profile-' . $this->owner->ID;
        }

        return $urlSegment;
    }
237008
public function getFragment(): string
    {
        if (!isset($this->segments['fragment'])) {
            throw new UrlException('Unable to get fragment for ' . $this->url);
        }

        return $this->segments['fragment'];
    }
793238
private static void appendPath(QPath relPath, StringBuilder buffer) {
         QPathEntry[] elements = relPath.getEntries();
        String slash = "";
        for (int i = 0; i < elements.length; i++) {
            buffer.append(slash);
            slash = "/";
            buffer.append(elements[i].getAsString(true));
        }
    }
832475
public function getCurrentPath()
    {
        $this->pathSegments = array_slice($this->pathSegments, 0, $this->pathLength);

        return $this->pathLength ? '/'.implode('/', $this->pathSegments) : '';
    }
457157
public function prepend($segment)
    {
        $segments = is_array($segment) ? $segment : func_get_args();

        $newPath = $this->path->copy();

        foreach (array_reverse($segments) as $segment) {
            $newPath->prepend($segment);
        }

        return $this->replicate(['path' => $newPath]);
    }
916859
public function buildUrl()
    {

        if (isset($this->otherOptions['urlProcessRegEx'])
            && !empty($this->otherOptions['urlProcessRegEx'])
        ) {
            unset($this->otherOptions['urlProcessPattern']);
        }

        if (isset($this->otherOptions['urlCrawlRegEx'])
            && !empty($this->otherOptions['urlCrawlRegEx'])
        ) {
            unset($this->otherOptions['urlCrawlPattern']);
        }


        // Add token
        $url = 'token=' . $this->diffbot->getToken();

        if ($this->getName()) {
            // Add name
            $url .= '&name=' . $this->getName();

            // Add seeds
            if (!empty($this->seeds)) {
                $url .= '&seeds=' . implode('%20', array_map(function ($item) {
                        return urlencode($item);
                    }, $this->seeds));
            }

            // Add other options
            if (!empty($this->otherOptions)) {
                foreach ($this->otherOptions as $option => $value) {
                    $url .= '&' . $option . '=' . $value;
                }
            }

            // Add API link
            $url .= '&apiUrl=' . $this->getApiString();
        }

        return $url;
    }
891844
public Href path(final Object suffix) {
        return new Href(
            URI.create(
                new StringBuilder(
                    Href.TRAILING_SLASH.matcher(this.uri.toString())
                        .replaceAll("")
                )
                .append('/')
                .append(Href.encode(suffix.toString())).toString()
            ),
            this.params,
            this.fragment
        );
    }
1306395
private function createDomXpath()
    {
        $xpath = new \DOMXPath($this->document);

        if ($this->xml_mode) { // register all name spaces
            foreach ($xpath->query('namespace::*') as $node) {
                if ($node->prefix !== 'xml') {
                    $xpath->registerNamespace($node->prefix, $node->namespaceURI);
                }
            }
        }

        return $xpath;
    }