Ouzo\Utilities\Files::mimeType PHP Method

mimeType() public static method

Returns mime type for the given file path.
public static mimeType ( string $path ) : string
$path string
return string
    public static function mimeType($path)
    {
        $fileInfo = new finfo(FILEINFO_MIME_TYPE);
        return $fileInfo->file($path);
    }

Usage Example

Esempio n. 1
0
 /**
  * @test
  */
 public function shouldReturnMimeType()
 {
     //given
     $path = Path::join(ROOT_PATH, 'test', 'resources', 'logo.png');
     //when
     $mimeType = Files::mimeType($path);
     //then
     $this->assertEquals('image/png', $mimeType);
 }