FileTypeHelper
in package
A class to provide utilities for manipulating files by their type.
Tags
Table of Contents
Methods
- __construct() : mixed
- Constructor
- get_extension() : string
- Get the extension of a filename
- get_file_type() : string
- Atempt to find a file type for the given filename.
- get_mime_type() : string
- Get the mime type of a filename.
- is_archive() : bool
- Using the file extension, test if the filename provided is a known archive.
- is_audio() : bool
- Using mime types if possible, or extensions, test if the filename provided is a known audio file.
- is_document() : bool
- Using the file extension, test if the file name specified is a known document file.
- is_image() : bool
- Test if the file specified is an image.
- is_media() : bool
- Test if the file name specified is a known media (image, audio, video) file.
- is_readable() : bool
- Test if the file specified is readable
- is_thumb() : bool
- Test if the file specified is a thumbnail This method first tests if the file is an image, and then if it is also a thumbnail.
- is_video() : bool
- Using mime types if possible, or extensions, test if the filename provided is a known audio file.
- is_xml() : bool
- Test if the file name specified is a known XML file.
- update_config_extensions() : mixed
- A utility method to allow overriding the extensions used to identify files of a specific type
Methods
__construct()
Constructor
public
__construct(cms_config $config) : mixed
Parameters
- $config : cms_config
get_extension()
Get the extension of a filename
public
get_extension(string $filename) : string
Parameters
- $filename : string
Return values
stringget_file_type()
Atempt to find a file type for the given filename.
public
get_file_type(string $filename) : string
Parameters
- $filename : string
Return values
string —A FileType type constant describing the file type, if found.
get_mime_type()
Get the mime type of a filename.
public
get_mime_type(string $filename) : string
requires the finfo_open function.
Parameters
- $filename : string
Return values
stringis_archive()
Using the file extension, test if the filename provided is a known archive.
public
is_archive(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_audio()
Using mime types if possible, or extensions, test if the filename provided is a known audio file.
public
is_audio(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_document()
Using the file extension, test if the file name specified is a known document file.
public
is_document(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_image()
Test if the file specified is an image.
public
is_image(string $filename) : bool
This method will use the mime type if possible, otherwise an extension is used to determine if the file is an image.
Parameters
- $filename : string
Return values
boolis_media()
Test if the file name specified is a known media (image, audio, video) file.
public
is_media(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_readable()
Test if the file specified is readable
public
is_readable(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_thumb()
Test if the file specified is a thumbnail This method first tests if the file is an image, and then if it is also a thumbnail.
public
is_thumb(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_video()
Using mime types if possible, or extensions, test if the filename provided is a known audio file.
public
is_video(string $filename) : bool
Parameters
- $filename : string
Return values
boolis_xml()
Test if the file name specified is a known XML file.
public
is_xml(string $filename) : bool
Parameters
- $filename : string
Return values
boolupdate_config_extensions()
A utility method to allow overriding the extensions used to identify files of a specific type
protected
update_config_extensions(string $member[, string $str = '' ]) : mixed
Parameters
- $member : string
-
One of (_archive_extensions, _audio_extensions, _video_extensions, _xml_extensions, _document_extensions)
- $str : string = ''
-
A comma separated string of extensions for that file type