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'
        );
    }
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'
        );
    }
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' ) ; }
Strip the segment from the start of the given path.

@param string $segment
@param string $path
@return string Truncated path
@throws RuntimeException if the segment does not begin the path.
Strip the segment from the start of the given path .