| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
(no description)
| File Size: | 593 lines (23 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
File:: (29 methods):
__construct()
fromUrl()
fromDataUri()
fromBase64()
fromLocalPath()
detectAndProcessFile()
isHttpUrl()
isBase64()
getFileType()
isInline()
isRemote()
getUrl()
getBase64Data()
getDataUri()
getMimeType()
getMimeTypeObject()
isVideo()
isImage()
isAudio()
isText()
isDocument()
isMimeType()
determineMimeType()
getJsonSchema()
toArray()
isArrayShape()
fromArray()
assertArrayShape()
__clone()
| __construct(string $file, ?string $mimeType = null) X-Ref |
| Constructor. Passing a local file path is deprecated; use {@see File::fromLocalPath()} instead. When a local path is detected, an E_USER_DEPRECATED notice is emitted and the file is read. param: string $file The file string (http(s) URL, data URI, plain base64 data, or deprecated local path). param: string|null $mimeType The MIME type of the file (optional, required for plain base64 data). |
| fromUrl(string $url, ?string $mimeType = null) X-Ref |
| Creates a remote file from an http(s) URL. The URL is not fetched by the client; it is passed on to the provider. return: self The remote file. param: string $url The http(s) URL. param: string|null $mimeType The MIME type (optional, otherwise inferred from the URL path extension). |
| fromDataUri(string $dataUri, ?string $mimeType = null) X-Ref |
| Creates an inline file from a data URI (data:[mime/type];base64,[data]). return: self The inline file. param: string $dataUri The data URI. param: string|null $mimeType The MIME type (optional, overrides the MIME type embedded in the data URI). |
| fromBase64(string $base64, string $mimeType) X-Ref |
| Creates an inline file from plain base64-encoded data. return: self The inline file. param: string $base64 The base64-encoded data (without data URI prefix). param: string $mimeType The MIME type of the data. |
| fromLocalPath(string $path, ?string $mimeType = null) X-Ref |
| Creates an inline file by reading a file from the local filesystem. Never pass untrusted input (such as user input or API response data) to this method. return: self The inline file. param: string $path The path to the local file. Stream wrappers (e.g. ftp://, phar://) are not supported. param: string|null $mimeType The MIME type (optional, otherwise inferred from the file extension). |
| detectAndProcessFile(string $file, ?string $providedMimeType) X-Ref |
| Detects the file type and processes it accordingly. param: string $file The file string to process. param: string|null $providedMimeType The explicitly provided MIME type. |
| isHttpUrl(string $string) X-Ref |
| Checks if a string is an http(s) URL. return: bool True if the string is an http(s) URL. param: string $string The string to check. |
| isBase64(string $string) X-Ref |
| Checks if a string is plain base64 data (possibly empty). return: bool True if the string is plain base64 data. param: string $string The string to check. |
| getFileType() X-Ref |
| Gets the file type. return: FileTypeEnum The file type. |
| isInline() X-Ref |
| Checks if the file is an inline file. return: bool True if the file is inline (base64/data URI). |
| isRemote() X-Ref |
| Checks if the file is a remote file. return: bool True if the file is remote (URL). |
| getUrl() X-Ref |
| Gets the URL for remote files. return: string|null The URL, or null if not a remote file. |
| getBase64Data() X-Ref |
| Gets the base64-encoded data for inline files. return: string|null The plain base64-encoded data (without data URI prefix), or null if not an inline file. |
| getDataUri() X-Ref |
| Gets the data as a data URI for inline files. return: string|null The data URI in format: data:[mimeType];base64,[data], or null if not an inline file. |
| getMimeType() X-Ref |
| Gets the MIME type of the file as a string. return: string The MIME type string value. |
| getMimeTypeObject() X-Ref |
| Gets the MIME type object. return: MimeType The MIME type object. |
| isVideo() X-Ref |
| Checks if the file is a video. return: bool True if the file is a video. |
| isImage() X-Ref |
| Checks if the file is an image. return: bool True if the file is an image. |
| isAudio() X-Ref |
| Checks if the file is audio. return: bool True if the file is audio. |
| isText() X-Ref |
| Checks if the file is text. return: bool True if the file is text. |
| isDocument() X-Ref |
| Checks if the file is a document. return: bool True if the file is a document. |
| isMimeType(string $type) X-Ref |
| Checks if the file is a specific MIME type. return: bool True if the file is of the specified type. param: string $type The mime type to check (e.g. 'image', 'text', 'video', 'audio'). |
| determineMimeType(?string $providedMimeType, ?string $extractedMimeType, ?string $pathOrUrl) X-Ref |
| Determines the MIME type from various sources. return: MimeType The determined MIME type. param: string|null $providedMimeType The explicitly provided MIME type. param: string|null $extractedMimeType The MIME type extracted from data URI. param: string|null $pathOrUrl The file path or URL to extract extension from. |
| getJsonSchema() X-Ref |
| {@inheritDoc} |
| toArray() X-Ref |
| {@inheritDoc} return: FileArrayShape |
| isArrayShape(array $array) X-Ref |
| {@inheritDoc} This check is purely structural and never accesses the filesystem. |
| fromArray(array $array) X-Ref |
| {@inheritDoc} |
| assertArrayShape(array $array) X-Ref |
| Asserts that an array has a valid file array shape, without constructing the file. param: array<mixed> $array The array to check. |
| __clone() X-Ref |
| Performs a deep clone of the file. This method ensures that the MimeType value object is cloned to prevent any shared references between the original and cloned file. |
| Generated : Sun Nov 1 08:20:35 2026 | Cross-referenced by PHPXref |