class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface

Guesses the MIME type with the binary "file" (only available on *nix).

Methods

__construct(string $cmd = 'file -b --mime %s 2>/dev/null')

The $cmd pattern must contain a "%s" string that will be replaced with the file name to guess.

bool
isGuesserSupported()

Returns true if this guesser is supported.

string|null
guessMimeType(string $path)

Guesses the MIME type of the file with the given path.

Details

at line 36
__construct(string $cmd = 'file -b --mime %s 2>/dev/null')

The $cmd pattern must contain a "%s" string that will be replaced with the file name to guess.

The command output must start with the MIME type of the file.

Parameters

string $cmd The command to run to get the MIME type of a file

at line 44
bool isGuesserSupported()

Returns true if this guesser is supported.

Return Value

bool

at line 66
string|null guessMimeType(string $path)

Guesses the MIME type of the file with the given path.

Parameters

string $path The path to the file

Return Value

string|null The MIME type or null, if none could be guessed

Exceptions

LogicException If the guesser is not supported
InvalidArgumentException If the file does not exist or is not readable