SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesser

A singleton mime type guesser.

By default, all mime type guessers provided by the framework are installed (if available on the current OS/PHP setup). You can register custom guessers by calling the register() method on the singleton instance.

$guesser = MimeTypeGuesser::getInstance(); $guesser->register(new MyCustomMimeTypeGuesser());

The last registered guesser is preferred over previously registered ones.

Summary

No public properties found
No constants found
No protected methods found
N/A
File
vendorSymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesser.php
Package
Default
Class hierarchy
SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesser
Implements
SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesserInterface

Tags

author

Bernhard Schussek bschussek@gmail.com

Properties

$guessers

$guessers : array

All registered MimeTypeGuesserInterface instances

Type

array

Tags

None found

$instance

$instance : \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser

The singleton instance

Type

SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesser

Tags

None found

Methods

getInstance()

getInstance() : \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser

Returns the singleton instance

Returns

SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesser

static

Tags

None found

register()

register(\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface  $guesser) 

Registers a new mime type guesser

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

Parameters

SymfonyComponentHttpFoundationFileMimeTypeMimeTypeGuesserInterface $guesser

Tags

None found

guess()

guess(string  $path) : string

Tries to guess the mime type of the given file

The file 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 $path

The path to the file

Throws

LogicException
SymfonyComponentHttpFoundationFileExceptionFileNotFoundException
SymfonyComponentHttpFoundationFileExceptionAccessDeniedException

Returns

string —

The mime type or NULL, if none could be guessed

Tags

None found

__construct()

__construct() 

Registers all natively provided mime type guessers

Tags

None found