public function getSegment($index): ?string
    {
        $path = trim($this->path, '/');
        if (isset($path{0})) {
            $parts = explode('/', $path);
            if (array_key_exists($index, $parts)) {
                return $parts[$index];
            }
        }
        return null;
    }
public function getSegment($index): ?string
    {
        $path = trim($this->path, '/');
        if (isset($path{0})) {
            $parts = explode('/', $path);
            if (array_key_exists($index, $parts)) {
                return $parts[$index];
            }
        }
        return null;
    }
public function getSegment ( $ index ) : ? string { $ path = trim ( $ this -> path , '/' ) ; if ( isset ( $ path { 0 } ) ) { $ parts = explode ( '/' , $ path ) ; if ( array_key_exists ( $ index , $ parts ) ) { return $ parts [ $ index ] ; } } return null ; }
Returns the value of the path segment for the index specified or null if not found.

@param int $index the index of the path segment.
@return string|null The value of the path segment for the index specified or null if not found.
Returns the value of the path segment for the index specified or null if not found .