Wrap the given value segments.

@param  array  $segments
@return string
349437
protected function wrapSegments($segments)
    {
        return collect($segments)->map(function ($segment, $key) use ($segments) {
            return $key == 0 && count($segments) > 1
                            ? $this->wrapTable($segment)
                            : $this->wrapValue($segment);
        })->implode('.');
    }
491438
protected function _setRequest($segments = array()){
		$segments = $this->_validateRequest($segments);
		if (count($segments) == 0){
			return $this->uri->_reindex_segments();
		}

		$this->setClass($segments[0]);

		if (isset($segments[1]))
		{
			// A standard method request
			$this->method = $segments[1];
		}
		else
		{
			// This lets the "routed" segment array identify that the default
			// index method is being used.
			$segments[1] = 'index';
		}

		// Update our "routed" segment array to contain the segments.
		// Note: If there is no custom routing, this array will be
		// identical to $this->uri->segments
		$this->uri->rsegments = $segments;
	}
295112
private function getDynamicRouteIds(array $segments): array
    {
        $matched = [];
        $index = 0;

        do {
            $matched[] =
                $this->provider->getRoutesBySegmentValue($index, $segments[$index]) +
                $this->provider->getRoutesBySegmentValue($index, RouteDefinition::DYNAMIC_SEGMENT);
            $index++;
        } while (isset($segments[$index]));

        $matched[] = $this->provider->getRoutesBySegmentCount(\count($segments));

        return array_values(array_intersect_key(... $matched));
    }
1151884
public static function join(...$segments)
    {
        $path = array();
        foreach ($segments as $segment) {
            $path = array_merge($path, (array) $segment);
        }

        $path = array_map(function ($segment) {
            return trim($segment, DIRECTORY_SEPARATOR);
        }, $path);

        $path = array_filter($path);

        $path = implode(DIRECTORY_SEPARATOR, $path);

        // First segment slash.
        if ((is_array($segments[0]) && strpos($segments[0][0], DIRECTORY_SEPARATOR) === 0)
            || strpos($segments[0], DIRECTORY_SEPARATOR) === 0
        ) {
            return DIRECTORY_SEPARATOR . $path;
        }
        return $path;
    }
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;
    }
1375050
public function crumbs($segments)
    {

        $item = '';
        $crumbs = [];
        foreach ($segments as $segment):
            $item = $item . "/" . $segment;
            $crumbs["{$segment}"] = $item;
        endforeach;
        return $crumbs;
    }
574032
private function getTruncatedPath($segment, $path)
    {
        if ($path === $segment) {
            // Segment and path are same; return empty string
            return '';
        }

        $segmentLength = strlen($segment);
        if (strlen($path) > $segmentLength) {
            // Strip segment from start of path
            return substr($path, $segmentLength);
        }

        if ('/' === substr($segment, -1)) {
            // Re-try by submitting with / stripped from end of segment
            return $this->getTruncatedPath(rtrim($segment, '/'), $path);
        }

        // Segment is longer than path. There's an issue
        throw new RuntimeException(
            'Layer and request path have gone out of sync'
        );
    }
1095682
public function parse(&$segments)
    {
        $path = implode('/', $segments);
        $vars = array();

        $matches = array();
        if (preg_match('/(\d+)-([^\/]+)/', $path, $matches)) {
            $vars['alias'] = $matches[2];
            $path = str_replace($matches[0], $matches[1], $path);
            $segments = array_filter(explode('/', $path));
        }

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

        $matches = array();

        if (preg_match('/@(\w+)/', $path, $matches)) {
            $vars['oid'] = $matches[1];
            if (isset($matches[2])) {
                $vars['view'] = $matches[2];
            }
            $path = ltrim(str_replace($matches[0], '', $path), '/');
            $segments = array_filter(explode('/', $path));
        }

        $vars = array_merge($vars, parent::parse($segments));

        if (isset($vars['id']) && current($segments)) {
            $vars['alias'] = array_shift($segments);
        }

        return $vars;
    }
67997
protected function buildSegments(array $segments)
    {
        $pattern  = "";
        $patterns = [];
        $wildcardTokens = array_keys($this->wildcards);
        $wildcardRegex  = $this->wildcards;

        foreach ($segments as $n => $segment) {
            if ($segment === "" && $n !== 0) {
                throw new BadRouteException(BadRouteException::EMPTY_OPTIONAL_PARTS);
            }

            $patterns[] = $pattern .= str_replace($wildcardTokens, $wildcardRegex, $segment);
        }

        return $patterns;
    }
80920
public function wrap($value, $prefixAlias = false)
    {
        if ($this->isExpression($value)) {
            return $this->getValue($value);
        }
        // If the value being wrapped has a column alias we will need to separate out
        // the pieces so we can wrap each of the segments of the expression on it
        // own, and then joins them both back together with the "as" connector.
        if (strpos(strtolower($value), ' as ') !== false) {
            $segments = explode(' ', $value);
            if ($prefixAlias) {
                $segments[2] = $this->tablePrefix.$segments[2];
            }
            return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]);
        }
        $wrapped = [];
        $segments = explode('.', $value);
        // If the value is not an aliased table expression, we'll just wrap it like
        // normal, so if there is more than one segment, we will wrap the first
        // segments as if it was a table and the rest as just regular values.
        foreach ($segments as $key => $segment) {
            if ($key == 0 && count($segments) > 1) {
                $wrapped[] = $this->wrapTable($segment);
            } else {
                $wrapped[] = $this->wrapValue($segment);
            }
        }
        return implode('.', $wrapped);
    }
568194
protected function fragment(array $tokens): string
    {
        $data = Arr::map($tokens['tokens'] ?? $tokens, function (Token $token) {
            return $token->token;
        });

        return \str_replace(
            '. ',
            '.',
            \implode(' ', $data)
        );
    }
1287741
public function parse(&$segments)
    {
        $query = array('view' => 'page');

        if (!empty($segments)) {
            $query['layout'] = str_replace('-', '_', implode('/', $segments));
        }

        return $query;
    }
1175576
protected function createTree(array $segments) : array
    {
        $nodes = array_map(function (TextSegment $segment) {
            $text = new TextNode($segment->getText());

            // Wrap text node in each tag from the innermost to the outermost.
            $tags = array_reverse($segment->getTags());
            return array_reduce($tags, function (Node $child, Tag $tag) {
                return new TagNode($tag, [$child]);
            }, $text);
        }, $segments);

        return $this->optimizeTree($nodes);
    }
263988
public static function segment(Int $seg = 1) : String
    {
        $segments = self::segmentArray();

        if( $seg > 0 )
        {
            $seg -= 1;
        }
        elseif( $seg < 0 )
        {
            $count = count($segments);
            $seg   = $count + $seg;
        }

        $select = $segments[$seg] ?? false;

        if( ! empty($select) )
        {
            return $segments[$seg];
        }
        elseif( $select === '0' ) // 5.3.34[added]
        {
            return (int) $select;
        }

        return false;
    }
1158591
private function processService(array &$segments): array
    {
        // init
        $processed = [];

        foreach ($segments as &$seg) {
            $jsonsegment = $this->processSegment($seg, $this->xmlSvc, null);
            $processed[$jsonsegment['key']] = $jsonsegment['value'];
        }

        return $processed;
    }
704124
protected function getTarget($target, array $segments)
    {
        foreach ($segments as $segment) {
            if (!$target) {
                return;
            }

            $target = $target->{$segment};
        }

        return $target;
    }
420261
public function offsetSet($offset, $segment)
	{
		if (is_null($offset)) {
			$this->segments[] = (string) $segment;
		} else {
			$this->segments[$offset] = (string) $segment;
		}
	}