src/Path.php
public static function getFilenameWithoutExtension($path, $extension = null)
    {
        if ('' === $path) {
            return '';
        }

        Assert::string($path, 'The path must be a string. Got: %s');
        Assert::nullOrString($extension, 'The extension must be a string or null. Got: %s');

        if (null !== $extension) {
            // remove extension and trailing dot
            return rtrim(basename($path, $extension), '.');
        }

        return pathinfo($path, PATHINFO_FILENAME);
    }
public static function getFilenameWithoutExtension($path, $extension = null)
    {
        if ('' === $path) {
            return '';
        }

        Assert::string($path, 'The path must be a string. Got: %s');
        Assert::nullOrString($extension, 'The extension must be a string or null. Got: %s');

        if (null !== $extension) {
            // remove extension and trailing dot
            return rtrim(basename($path, $extension), '.');
        }

        return pathinfo($path, PATHINFO_FILENAME);
    }
public static function getFilenameWithoutExtension ( $ path , $ extension = null ) { if ( '' === $ path ) { return '' ; } Assert :: string ( $ path , 'The path must be a string. Got: %s' ) ; Assert :: nullOrString ( $ extension , 'The extension must be a string or null. Got: %s' ) ; if ( null !== $ extension ) { // remove extension and trailing dot return rtrim ( basename ( $ path , $ extension ) , '.' ) ; } return pathinfo ( $ path , PATHINFO_FILENAME ) ; }
Returns the file name without the extension from a file path.

@param string      $path      The path string.
@param string|null $extension If specified, only that extension is cut
off (may contain leading dot).

@return string The file name without extension.

@since 1.1 Added method.
@since 2.0 Method now fails if $path or $extension have invalid types.
Returns the file name without the extension from a file path .