FileType
in package
implements
MetaFoxFileTypeInterface
Table of Contents
Interfaces
Constants
- AUDIO_MIME_TYPE_REGEX = '/^audio\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
- AUDIO_MIMES_TYPES = 'audio/mp3'
- PHOTO_MIME_TYPE_REGEX = '/^image\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
- PHOTO_MIMES_TYPES = 'image/jpg,image/jpeg,image/png,image/gif,image/bmp,image/webp'
- VIDEO_MIME_TYPE_REGEX = '/^video\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
- VIDEO_MIMES_TYPES = 'video/*'
Properties
- $types : array<string|int, string>
Methods
- getAllowableTypes() : array<string|int, string>
- getFilesizeInMegabytes() : float
- getFilesizePerType() : int
- This method return how many bytes should a type can be uploaded to server.
- getFilesizeReadableString() : string
- getMimeTypeFromType() : string
- getTypeByMime() : string|null
- isAllowType() : bool
- transformFileType() : string
- verifyMime() : bool
- verifyMimeTypeByType() : bool
- verifyAudioMimeType() : bool
- verifyImageMimeType() : bool
- verifyVideoMimeType() : bool
Constants
AUDIO_MIME_TYPE_REGEX
public
mixed
AUDIO_MIME_TYPE_REGEX
= '/^audio\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
AUDIO_MIMES_TYPES
public
mixed
AUDIO_MIMES_TYPES
= 'audio/mp3'
PHOTO_MIME_TYPE_REGEX
public
mixed
PHOTO_MIME_TYPE_REGEX
= '/^image\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
PHOTO_MIMES_TYPES
public
mixed
PHOTO_MIMES_TYPES
= 'image/jpg,image/jpeg,image/png,image/gif,image/bmp,image/webp'
VIDEO_MIME_TYPE_REGEX
public
mixed
VIDEO_MIME_TYPE_REGEX
= '/^video\\/([a-zA-Z0-9\\.\\-\\+]+)$/m'
VIDEO_MIMES_TYPES
public
mixed
VIDEO_MIMES_TYPES
= 'video/*'
Properties
$types
public
static array<string|int, string>
$types
= [\MetaFox\Platform\MetaFoxFileType::PHOTO_TYPE => self::PHOTO_MIMES_TYPES, \MetaFox\Platform\MetaFoxFileType::VIDEO_TYPE => self::VIDEO_MIMES_TYPES, \MetaFox\Platform\MetaFoxFileType::AUDIO_TYPE => self::AUDIO_MIMES_TYPES]
Methods
getAllowableTypes()
public
getAllowableTypes(string $type[, bool $useConverter = true ]) : array<string|int, string>
Parameters
- $type : string
- $useConverter : bool = true
Tags
Return values
array<string|int, string>getFilesizeInMegabytes()
public
getFilesizeInMegabytes(string $type) : float
Parameters
- $type : string
Return values
floatgetFilesizePerType()
This method return how many bytes should a type can be uploaded to server.
public
getFilesizePerType(string $type) : int
Parameters
- $type : string
Tags
Return values
intgetFilesizeReadableString()
public
getFilesizeReadableString(int $bytes) : string
Parameters
- $bytes : int
Tags
Return values
stringgetMimeTypeFromType()
public
getMimeTypeFromType(string $type[, bool $useConverter = true ]) : string
Parameters
- $type : string
- $useConverter : bool = true
Tags
Return values
stringgetTypeByMime()
public
getTypeByMime(string|null $mimeType) : string|null
Parameters
- $mimeType : string|null
Tags
Return values
string|nullisAllowType()
public
isAllowType(string $type) : bool
Parameters
- $type : string
Return values
booltransformFileType()
public
transformFileType(string $fileType) : string
Parameters
- $fileType : string
Return values
stringverifyMime()
public
verifyMime(UploadedFile $file, string $type) : bool
Parameters
- $file : UploadedFile
- $type : string
Return values
boolverifyMimeTypeByType()
public
verifyMimeTypeByType(string|null $mimeType[, string $fileType = 'photo' ]) : bool
Parameters
- $mimeType : string|null
- $fileType : string = 'photo'
Return values
boolverifyAudioMimeType()
protected
verifyAudioMimeType(string $mimeType) : bool
Parameters
- $mimeType : string
Return values
boolverifyImageMimeType()
protected
verifyImageMimeType(string $mimeType) : bool
Parameters
- $mimeType : string
Return values
boolverifyVideoMimeType()
protected
verifyVideoMimeType(string $mimeType) : bool
Parameters
- $mimeType : string