class ExtensionGuesser implements ExtensionGuesserInterface

deprecated since Symfony 4.3, use {@link MimeTypes} instead

A singleton mime type to file extension guesser.

A default guesser is provided. You can register custom guessers by calling the register() method on the singleton instance:

$guesser = ExtensionGuesser::getInstance();
$guesser->register(new MyCustomExtensionGuesser());

The last registered guesser is preferred over previously registered ones.

Properties

protected array $guessers All registered ExtensionGuesserInterface instances.

Methods

getInstance()

Returns the singleton instance.

register(ExtensionGuesserInterface $guesser)

Registers a new extension guesser.

string
guess(string $mimeType)

Tries to guess the extension.

Details

at line 53
static ExtensionGuesser getInstance()

Returns the singleton instance.

Return Value

ExtensionGuesser

at line 75
register(ExtensionGuesserInterface $guesser)

Registers a new extension guesser.

When guessing, this guesser is preferred over previously registered ones.

Parameters

ExtensionGuesserInterface $guesser

at line 92
string guess(string $mimeType)

Tries to guess the extension.

The mime type is passed to each registered mime type guesser in reverse order of their registration (last registered is queried first). Once a guesser returns a value that is not NULL, this method terminates and returns the value.

Parameters

string $mimeType The mime type

Return Value

string The guessed extension or NULL, if none could be guessed