Delocalizes segments in path
@param array $segments
340680
public function delocalizeSegments(array &$segments)
    {
        if (count($segments) > 0) {
            $locale = $segments[0];
            if ($this->localeHelper->isValidLocale($locale)) {
                array_shift($segments);
            }
        }
    }
1343918
public function append($segment)
    {
        $segments = is_array($segment) ? $segment : func_get_args();

        return $this->replicate(['path' => $this->path->copy()->extend($segments)]);
    }
250160
protected static function convertPathToTree(array &$paths, $index, $path)
    {
        if (strpos($path, DIRECTORY_SEPARATOR) !== false) {
            $chunks = explode(DIRECTORY_SEPARATOR, $path);
            $paths = static::branch($paths, $chunks);
            unset($paths[$index]);
        }
    }
691391
public static function remove(array &$array, string $path): void
    {
        $paths = explode('.', $path);
        $lastKey = array_pop($paths);
        $temp = &$array;
        while ($key = array_shift($paths)) {
            if (isset($temp[$key])) {
                $temp = &$temp[$key];
            } else {
                return;
            }
        }
        unset($temp[$lastKey]);
    }
780006
public static function untrailingslash(&$path) {
		if (\is_array($path)) {
			foreach ($path as $k=>$v) {
				static::untrailingslash($path[$k]);
			}
		}
		else {
			cast::string($path, true);

			static::unixslash($path);
			$path = \rtrim($path, '/');
		}
	}
1074656
public function parse(&$segments)
    {
        $path = implode('/', $segments);
        $query = array();

        // if (count($segments) && strpos($segments[0], '@') === 0) {
        //    $query['oid'] = str_replace('@', '', array_shift($segments));
        // }

        $query['view'] = array_shift($segments);

        if (preg_match('#server\/\w+#', $path)) {
            array_shift($segments);
            $query['server'] = array_shift($segments);
        }

        if (
              isset($query['server']) &&
              count($segments) &&
              $segments[0] == 'token'
        ) {
            $query['get'] = 'accesstoken';
        }

        return $query;
    }
556980
public static function removeDotSegments($path)
    {
        static $noopPaths = array('' => true, '/' => true, '*' => true);
        static $ignoreSegments = array('.' => true, '..' => true);

        if (isset($noopPaths[$path])) {
            return $path;
        }

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

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

        // Add the trailing slash if necessary
        if ($newPath != '/' && isset($ignoreSegments[end($segments)])) {
            $newPath .= '/';
        }

        return $newPath;
    }
819332
public function parse(&$segments)
    {
        $path = implode('/', $segments);

        if (empty($segments)) {
            $segments[] = 'email';
        }

        if (preg_match('#(connections|token)(/\w+)?#', $path)) {
            return array(
                'view' => array_shift($segments),
                'service' => pick('facebook', array_pop($segments)),
            );
        }

        return parent::parse($segments);
    }
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;
    }
528441
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));
        }

        $last = AnHelperArray::getValueAtIndex($segments, AnHelperArray::LAST_INDEX);

        if (preg_match('/@\w+/', $last)) {
            $vars['oid'] = str_replace('@', '', array_pop($segments));
        }

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

        if (isset($vars['get']) && $vars['get'] == 'graph') {
            $vars['type'] = count($segments) ? array_shift($segments) : 'followers';
        }

        return $vars;
    }
897304
private function removeTrailingDomainSlashes(array $locales)
    {
        foreach ($locales as $scopeKey => $segments) {
            unset($locales[$scopeKey]);
            $locales[rtrim($scopeKey, '/')] = $segments;
        }

        return $locales;
    }
557495
protected function routeDefault($segments = array(), $route)
    {
        // If we don't have any segments left - try the default controller;
        // WARNING: Directories get shifted out of the segments array!
        if (empty($segments))
        {
            $segments[0] = $this->config->routing->default_controller;
        }

        if ($this->config->routing->translate_uri_dashes === true)
        {
            $segments[0] = str_replace('-', '_', $segments[0]);
            if (isset($segments[1]))
            {
                $segments[1] = str_replace('-', '_', $segments[1]);
            }
        }

        // Prepare the values for loading
        $controller = $segments[0];
        $function = (isset($segments[1]) ? $segments[1] : $this->config->routing->default_function);

        // And prepare the Router URI
        array_unshift($segments, null);
        unset($segments[0]);
        $this->uri->rsegments = $segments;

        // Now create a matches array
        $matches = array(
                'controller' => $controller,
                'function' => $function,
                'parameters' => array_slice($this->uri->rsegments, 2)
            );

        // And finally load the callable
        $this->callable = array('\FuzeWorks\Router', 'defaultCallable');
        $this->loadCallable($matches, $route);
    }
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;
    }
1240219
public static function delete(array &$values, $path)
    {
        /** @noinspection ReferenceMismatchInspection */
        if (!static::isArray($values)) {
            // This is not an array!
            return false;
        }

        if (is_array($path)) {
            // The path has already been separated into segments
            $segments = $path;
        } else {
            $path = (string) $path;

            // Remove starting delimiters and spaces
            $path = ltrim($path, sprintf('%s ', static::PATH_DELIMITER));
            // Remove ending delimiters, spaces, and wildcards
            $path = rtrim($path, sprintf('%s %s', static::PATH_DELIMITER, static::PATH_WILDCARD));
            // Split the segments by delimiter
            $segments = explode(static::PATH_DELIMITER, $path);
        }

        while (count($segments) > 1) {
            $key = array_shift($segments);

            /** @noinspection ReferenceMismatchInspection */
            if (!array_key_exists($key, $values) || !is_array($values[$key])) {
                return false;
            }

            $values =& $values[$key];
        }

        unset($values[array_shift($segments)]);

        return true;
    }
536558
protected function removeDotSegments($path)
    {
        if ($path === null) {
            throw new \InvalidArgumentException('Path not set');
        }

        // §5.2.4.  Remove Dot Segments
        $input  = $path;
        $output = '';

        while ($input != '') {
            if (substr($input, 0, 3) == '../') {
                $input = (string) substr($input, 3);
            } elseif (substr($input, 0, 2) == './') {
                $input = (string) substr($input, 2);
            } elseif (substr($input, 0, 3) == '/./') {
                $input = substr($input, 2);
            } elseif ($input == '/.') {
                $input = '/';
            } elseif (substr($input, 0, 4) == '/../') {
                $input  = substr($input, 3);
                $pos    = strrpos($output, '/');
                if ($pos === false) {
                    $output = '';
                } else {
                    $output = substr($output, 0, $pos);
                }
            } elseif ($input == '/..') {
                $input  = '/';
                $pos    = strrpos($output, '/');
                if ($pos === false) {
                    $output = '';
                } else {
                    $output = substr($output, 0, $pos);
                }
            } elseif ($input == '.' || $input == '..') {
                $input = '';
            } else {
                $pos = strpos($input, '/', 1);
                if ($pos === false) {
                    $output    .= $input;
                    $input      = '';
                } else {
                    $output    .= substr($input, 0, $pos);
                    $input      = substr($input, $pos);
                }
            }
        }

        return $output;
    }
274717
public function addSegments($segments)
    {
        if ( ! $segments instanceof Segments) {
            $segments = new Segments($segments);
        }

        $currentSegments = $this->segments->getParts();
        $addSegments = $segments->getParts();

        $uri = clone $this;
        $uri->segments = new Segments(array_merge($currentSegments, $addSegments));

        return $uri;
    }
78143
public static function setLastSegment($segments)
    {
        if (is_array($segments)) {
            $vars = $segments;
        } else {
            $vars = self::segmentUrl($segments);
        }

        return end($vars);
    }