PhpOffice\PhpPresentation\Reader\ODPresentation::fileSupportsUnserializePhpPresentation PHP Method

fileSupportsUnserializePhpPresentation() public method

Does a file support UnserializePhpPresentation ?
public fileSupportsUnserializePhpPresentation ( string $pFilename = '' ) : boolean
$pFilename string
return boolean
    public function fileSupportsUnserializePhpPresentation($pFilename = '')
    {
        // Check if file exists
        if (!file_exists($pFilename)) {
            throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
        }
        $oZip = new ZipArchive();
        // Is it a zip ?
        if ($oZip->open($pFilename) === true) {
            // Is it an OpenXML Document ?
            // Is it a Presentation ?
            if (is_array($oZip->statName('META-INF/manifest.xml')) && is_array($oZip->statName('mimetype')) && $oZip->getFromName('mimetype') == 'application/vnd.oasis.opendocument.presentation') {
                return true;
            }
        }
        return false;
    }

Usage Example

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Could not open  for reading! File does not exist.
  */
 public function testFileSupportsNotExists()
 {
     $object = new ODPresentation();
     $object->fileSupportsUnserializePhpPresentation('');
 }