MediaValidator
in package
Media file validator.
Validates uploaded files against configuration rules.
Table of Contents
Properties
- $_errors : array<string|int, mixed>
- $_settings : SettingManager
Methods
- __construct() : mixed
- Constructor
- getErrors() : array<string|int, mixed>
- Get validation errors
- getFirstError() : string|null
- Get first validation error
- validate() : bool
- Validate an uploaded file
- getUploadErrorMessage() : string
- Get upload error message
- validateFileSize() : bool
- Validate file size
- validateFileType() : bool
- Validate file type
Properties
$_errors
private
array<string|int, mixed>
$_errors
= []
$_settings
private
SettingManager
$_settings
Methods
__construct()
Constructor
public
__construct(SettingManager $settings) : mixed
Parameters
- $settings : SettingManager
-
Application settings manager
getErrors()
Get validation errors
public
getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of error messages
getFirstError()
Get first validation error
public
getFirstError() : string|null
Return values
string|null —First error message or null if no errors
validate()
Validate an uploaded file
public
validate(array<string|int, mixed> $file) : bool
Parameters
- $file : array<string|int, mixed>
-
PHP $_FILES array entry
Return values
bool —True if valid, false otherwise
getUploadErrorMessage()
Get upload error message
private
getUploadErrorMessage(int $error) : string
Parameters
- $error : int
-
PHP upload error code
Return values
string —Error message
validateFileSize()
Validate file size
private
validateFileSize(int $size) : bool
Parameters
- $size : int
-
File size in bytes
Return values
bool —True if valid
validateFileType()
Validate file type
private
validateFileType(string $filePath, string $fileName) : bool
Parameters
- $filePath : string
-
Path to the file
- $fileName : string
-
Original filename
Return values
bool —True if valid