wppaste
WordPress

MimeType

Since
0.1.0
Source
wp-includes/php-ai-client/src/Files/ValueObjects/MimeType.php:15
Value object representing a MIME type.

Description

This immutable value object encapsulates MIME type validation and provides convenient methods for checking MIME type categories.

Compatibility

WordPress
since 0.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 2 of the 5 tracked releases, added in 0.1.0.

Properties · 3

$valuestringprivate
$extensionMapWordPress\AiClient\Files\ValueObjects\array<string,private static
Common MIME type mappings for file extensions.
$documentTypesWordPress\AiClient\Files\ValueObjects\array<string>private static
Document MIME types.

Methods · 12

Source code

final class MimeType{    /**     * @var string The MIME type value.     */    private string $value;    /**     * Common MIME type mappings for file extensions.     *     * @var array<string, string>     */    private static array $extensionMap = [        // Text        'txt' => 'text/plain',        'html' => 'text/html',        'htm' => 'text/html',        'css' => 'text/css',        'js' => 'application/javascript',        'json' => 'application/json',        'xml' => 'application/xml',        'csv' => 'text/csv',        'md' => 'text/markdown',        // Images        'jpg' => 'image/jpeg',        'jpeg' => 'image/jpeg',        'png' => 'image/png',        'gif' => 'image/gif',        'bmp' => 'image/bmp',        'webp' => 'image/webp',        'svg' => 'image/svg+xml',        'ico' => 'image/x-icon',        // Documents        'pdf' => 'application/pdf',        'doc' => 'application/msword',        'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',        'xls' => 'application/vnd.ms-excel',        'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',        'ppt' => 'application/vnd.ms-powerpoint',        'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',        'odt' => 'application/vnd.oasis.opendocument.text',        'ods' => 'application/vnd.oasis.opendocument.spreadsheet',        // Archives        'zip' => 'application/zip',        'tar' => 'application/x-tar',        'gz' => 'application/gzip',        'rar' => 'application/x-rar-compressed',        '7z' => 'application/x-7z-compressed',        // Audio        'mp3' => 'audio/mpeg',        'wav' => 'audio/wav',        'ogg' => 'audio/ogg',        'flac' => 'audio/flac',        'm4a' => 'audio/m4a',        'aac' => 'audio/aac',        // Video        'mp4' => 'video/mp4',        'avi' => 'video/x-msvideo',        'mov' => 'video/quicktime',        'wmv' => 'video/x-ms-wmv',        'flv' => 'video/x-flv',        'webm' => 'video/webm',        'mkv' => 'video/x-matroska',        // Fonts        'ttf' => 'font/ttf',        'otf' => 'font/otf',        'woff' => 'font/woff',        'woff2' => 'font/woff2',        // Other        'php' => 'application/x-httpd-php',        'sh' => 'application/x-sh',        'exe' => 'application/x-msdownload',    ];    /**     * Document MIME types.     *     * @var array<string>     */    private static array $documentTypes = ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet'];    /**     * Constructor.

Changelog

Introduced in 0.1.0. Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 7.1.0

Signature, return type and hooks compared across 2 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/php-ai-client/src/Files/ValueObjects/MimeType.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.