assertFile.php
Table of Contents
Functions
- assertFile() : void
- Asserts that a file exists and meets specified accessibility and MIME type requirements.
Functions
assertFile()
Asserts that a file exists and meets specified accessibility and MIME type requirements.
assertFile(string|null $file[, array<string|int, mixed>|null $expectedMimeTypes = null ][, bool $isReadable = true ][, bool $isWritable = false ]) : void
This function performs a series of checks on a given file:
- Ensures the file path is not null or empty.
- Confirms that the path points to a valid file.
- Optionally checks if the file is readable.
- Optionally checks if the file is writable.
- Optionally validates the file's MIME type against a provided list.
Parameters
- $file : string|null
-
The path of the file to check. Cannot be null or empty.
- $expectedMimeTypes : array<string|int, mixed>|null = null
-
Optional array of allowed MIME types. If provided, the file's MIME type must match one of these.
- $isReadable : bool = true
-
Whether to assert that the file is readable. Default: true.
- $isWritable : bool = false
-
Whether to assert that the file is writable. Default: false.