Zend\Stratigility\Next::getTruncatedPath PHP Method

getTruncatedPath() private method

Strip the segment from the start of the given path.
private getTruncatedPath ( string $segment, string $path ) : string
$segment string
$path string
return string Truncated path
    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');
    }