It should be mentioned that the function returns the name of the directory if "filename" is of type "directory". Hence
$info = new SplFileInfo('/path/to/');
should return "to"
The function name is kind of misleading here and I am glad to have it tried.