Skip to content

Commit

Permalink
[5.5] Add mov extension and search method in MIME types (#20917)
Browse files Browse the repository at this point in the history
* Add mov extension.

* Add search method.
  • Loading branch information
mathieutu authored and taylorotwell committed Sep 1, 2017
1 parent 92ce1f7 commit 475e52a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Illuminate/Http/Testing/MimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
*
Expand Down
6 changes: 6 additions & 0 deletions tests/Http/HttpMimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}

0 comments on commit 475e52a

Please sign in to comment.