From 475e52af84911a7d66d4fc6821c73ed754a280df Mon Sep 17 00:00:00 2001 From: Mathieu TUDISCO Date: Fri, 1 Sep 2017 18:23:33 +0200 Subject: [PATCH] [5.5] Add mov extension and search method in MIME types (#20917) * Add mov extension. * Add search method. --- src/Illuminate/Http/Testing/MimeType.php | 12 ++++++++++++ tests/Http/HttpMimeTypeTest.php | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/Illuminate/Http/Testing/MimeType.php b/src/Illuminate/Http/Testing/MimeType.php index f499a3def0ea..b4212ae25ed9 100644 --- a/src/Illuminate/Http/Testing/MimeType.php +++ b/src/Illuminate/Http/Testing/MimeType.php @@ -747,6 +747,7 @@ class MimeType 'mp4' => 'video/mp4', 'mpeg' => 'video/mpeg', 'ogv' => 'video/ogg', + 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'uvh' => 'video/vnd.dece.hd', 'uvm' => 'video/vnd.dece.mobile', @@ -802,6 +803,17 @@ public static function get($extension = null) return $extension ? self::getMimeTypeFromExtension($extension) : self::$mimes; } + /** + * Search for the extension of a given MIME type. + * + * @param string $mimeType + * @return string|null + */ + public static function search($mimeType) + { + return array_search($mimeType, self::$mimes) ?: null; + } + /** * Get the MIME type for a given extension. * diff --git a/tests/Http/HttpMimeTypeTest.php b/tests/Http/HttpMimeTypeTest.php index 542b56188d4a..984627e4cd07 100755 --- a/tests/Http/HttpMimeTypeTest.php +++ b/tests/Http/HttpMimeTypeTest.php @@ -32,4 +32,10 @@ public function testGetAllMimeTypes() $this->assertInternalType('array', MimeType::get()); $this->assertArraySubset(['jpg' => 'image/jpeg'], MimeType::get()); } + + public function testSearchExtensionFromMimeType() + { + $this->assertSame('mov', MimeType::search('video/quicktime')); + $this->assertSame(null, MimeType::search('foo/bar')); + } }