MimeType::toExtension(): string

In this article

Gets the primary known file extension for this MIME type.

Return

string The file extension (without the dot).

Source

public function toExtension(): string
{
    // Reverse lookup for the MIME type to find the extension.
    $extension = array_search($this->value, self::$extensionMap, \true);
    if ($extension === \false) {
        throw new InvalidArgumentException(sprintf('No known extension for MIME type: %s', $this->value));
    }
    return $extension;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.