src/ScContent/Filter/File/MimeType.php
public function setMagicFile($file)
    {
        if ($file === false) {
            $this->options['magicFile'] = false;
        } elseif (empty($file)) {
            $this->options['magicFile'] = null;
        } elseif (! (class_exists('finfo', false))) {
            $this->options['magicFile'] = null;
            throw new Exception\RuntimeException(
                'Magicfile can not be set; there is no finfo extension installed'
            );
        } elseif (! is_file($file) || ! is_readable($file)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'The given magicfile ("%s") could not be read',
                $file
            ));
        } else {
            ErrorHandler::start(E_NOTICE|E_WARNING);
            $this->finfo = finfo_open(FILEINFO_MIME_TYPE, $file);
            $error       = ErrorHandler::stop();
            if (empty($this->finfo)) {
                $this->finfo = null;
                throw new Exception\InvalidArgumentException(sprintf(
                    'The given magicfile ("%s") could not be used by ext/finfo',
                    $file
                ), 0, $error);
            }
            $this->options['magicFile'] = $file;
        }

        return $this;
    }
public function setMagicFile($file)
    {
        if ($file === false) {
            $this->options['magicFile'] = false;
        } elseif (empty($file)) {
            $this->options['magicFile'] = null;
        } elseif (! (class_exists('finfo', false))) {
            $this->options['magicFile'] = null;
            throw new Exception\RuntimeException(
                'Magicfile can not be set; there is no finfo extension installed'
            );
        } elseif (! is_file($file) || ! is_readable($file)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'The given magicfile ("%s") could not be read',
                $file
            ));
        } else {
            ErrorHandler::start(E_NOTICE|E_WARNING);
            $this->finfo = finfo_open(FILEINFO_MIME_TYPE, $file);
            $error       = ErrorHandler::stop();
            if (empty($this->finfo)) {
                $this->finfo = null;
                throw new Exception\InvalidArgumentException(sprintf(
                    'The given magicfile ("%s") could not be used by ext/finfo',
                    $file
                ), 0, $error);
            }
            $this->options['magicFile'] = $file;
        }

        return $this;
    }
public function setMagicFile ( $ file ) { if ( $ file === false ) { $ this -> options [ 'magicFile' ] = false ; } elseif ( empty ( $ file ) ) { $ this -> options [ 'magicFile' ] = null ; } elseif ( ! ( class_exists ( 'finfo' , false ) ) ) { $ this -> options [ 'magicFile' ] = null ; throw new Exception \ RuntimeException ( 'Magicfile can not be set; there is no finfo extension installed' ) ; } elseif ( ! is_file ( $ file ) || ! is_readable ( $ file ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'The given magicfile ("%s") could not be read' , $ file ) ) ; } else { ErrorHandler :: start ( E_NOTICE | E_WARNING ) ; $ this -> finfo = finfo_open ( FILEINFO_MIME_TYPE , $ file ) ; $ error = ErrorHandler :: stop ( ) ; if ( empty ( $ this -> finfo ) ) { $ this -> finfo = null ; throw new Exception \ InvalidArgumentException ( sprintf ( 'The given magicfile ("%s") could not be used by ext/finfo' , $ file ) , 0 , $ error ) ; } $ this -> options [ 'magicFile' ] = $ file ; } return $ this ; }
Sets the magicfile to use
if null, the MAGIC constant from php is used
if the MAGIC file is erroneous, no file will be set
if false, the default MAGIC file from PHP will be used

@param  string $file
@throws \Zend\Filter\Exception\RuntimeException When finfo can not read the magicfile
@throws \Zend\Filter\Exception\InvalidArgumentException
@return MimeType Provides fluid interface
Sets the magicfile to use if null the MAGIC constant from php is used if the MAGIC file is erroneous no file will be set if false the default MAGIC file from PHP will be used