PhpOffice\PhpPresentation\Shape\Media::getMimeType PHP Method

getMimeType() public method

public getMimeType ( ) : string
return string
    public function getMimeType()
    {
        switch (strtolower($this->getExtension())) {
            case 'mp4':
                $mimetype = 'video/mp4';
                break;
            case 'ogv':
                $mimetype = 'video/ogg';
                break;
            case 'wmv':
                $mimetype = 'video/x-ms-wmv';
                break;
            default:
                $mimetype = 'application/octet-stream';
        }
        return $mimetype;
    }

Usage Example

Example #1
0
 public function testMimeType()
 {
     $object = new Media();
     $object->setPath('file.mp4', false);
     $this->assertEquals('video/mp4', $object->getMimeType());
     $object->setPath('file.ogv', false);
     $this->assertEquals('video/ogg', $object->getMimeType());
     $object->setPath('file.wmv', false);
     $this->assertEquals('video/x-ms-wmv', $object->getMimeType());
     $object->setPath('file.xxx', false);
     $this->assertEquals('application/octet-stream', $object->getMimeType());
 }