Elgg  Version master
Public Member Functions | List of all members
Elgg\Filesystem\MimeTypeService Class Reference

Public service related to MIME type detection. More...

Public Member Functions

 __construct (protected EventsService $events)
 Constructor. More...
 
 getMimeType (string $filename, string $default=MimeTypeDetector::DEFAULT_TYPE)
 Get the mimetype for a given filename. More...
 
 getSimpleType (string $mimetype, string $default= 'general')
 Returns the category of a file from its MIME type. More...
 
 getSimpleTypeFromFile (string $filename, string $default= 'general')
 Returns the category of a file from a filename. More...
 

Detailed Description

Public service related to MIME type detection.

Since
3.3

Definition at line 13 of file MimeTypeService.php.

Constructor & Destructor Documentation

Elgg\Filesystem\MimeTypeService::__construct ( protected EventsService  $events)

Constructor.

Parameters
EventsService$eventsEvents service

Definition at line 20 of file MimeTypeService.php.

Member Function Documentation

Elgg\Filesystem\MimeTypeService::getMimeType ( string  $filename,
string  $default = MimeTypeDetector::DEFAULT_TYPE 
)

Get the mimetype for a given filename.

Parameters
string$filenameFilename to check
string$defaultDefault mimetype if not detected (default: application/octet-stream)
Exceptions
InvalidArgumentException
Returns
string

Definition at line 32 of file MimeTypeService.php.

Elgg\Filesystem\MimeTypeService::getSimpleType ( string  $mimetype,
string  $default = 'general' 
)

Returns the category of a file from its MIME type.

Parameters
string$mimetypeThe MIME type
string$defaultDefault MIME type if detection fails (default: general)
Returns
string

Definition at line 58 of file MimeTypeService.php.

Elgg\Filesystem\MimeTypeService::getSimpleTypeFromFile ( string  $filename,
string  $default = 'general' 
)

Returns the category of a file from a filename.

Parameters
string$filenameThe filename to check
string$defaultDefault MIME type if detection fails (default: general)
Returns
string

Definition at line 95 of file MimeTypeService.php.


The documentation for this class was generated from the following file: