protected function validMimeType($input): void
    {
        if (is_null($this->path)) {
            throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path');
        }
        if (! is_null($input)) {
            if (! is_string($input)) {
                throw \AWonderPHP\FileWrapper\TypeErrorException::mimeWrongType($input);
            }
            $input = trim(strtolower($input));
            try {
                $input = $this->mimeTypoFix($input);
            } catch (\ErrorException $e) {
                error_log($e->getMessage());
                $this->internalError = true;
                return;
            }
            if (in_array($input, $this->validMime)) {
                $this->mime = $input;
                return;
            }
        }
        // do what we can
        if ($input == "application/octet-stream") {
            $input = null;
        }
        $error = false;
        if (! is_null($input)) {
            $arr = explode('/', $input);
            if (count($arr) != 2) {
                $error = true;
            } elseif (! in_array($arr[0], array('application',
                                                'audio',
                                                'font',
                                                'image',
                                                'multipart',
                                                'text',
                                                'video'))) {
                $error = true;
            }
            if ($error) {
                if (function_exists('finfo_open')) {
                    if ($finfo = finfo_open(FILEINFO_MIME_TYPE)) {
                        if ($mime = finfo_file($finfo, $this->path)) {
                            try {
                                $this->mime = $this->mimeTypoFix($mime);
                            } catch (\ErrorException $e) {
                                error_log($e->getMessage());
                                $this->internalError = true;
                            }
                            finfo_close($finfo);
                            return;
                        }
                        finfo_close($finfo);
                    }
                }
            }
        }
        if (is_null($input)) {
            $input = 'application/octet-stream';
        }
        $this->mime = $input;
    }
protected function validMimeType($input): void
    {
        if (is_null($this->path)) {
            throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path');
        }
        if (! is_null($input)) {
            if (! is_string($input)) {
                throw \AWonderPHP\FileWrapper\TypeErrorException::mimeWrongType($input);
            }
            $input = trim(strtolower($input));
            try {
                $input = $this->mimeTypoFix($input);
            } catch (\ErrorException $e) {
                error_log($e->getMessage());
                $this->internalError = true;
                return;
            }
            if (in_array($input, $this->validMime)) {
                $this->mime = $input;
                return;
            }
        }
        // do what we can
        if ($input == "application/octet-stream") {
            $input = null;
        }
        $error = false;
        if (! is_null($input)) {
            $arr = explode('/', $input);
            if (count($arr) != 2) {
                $error = true;
            } elseif (! in_array($arr[0], array('application',
                                                'audio',
                                                'font',
                                                'image',
                                                'multipart',
                                                'text',
                                                'video'))) {
                $error = true;
            }
            if ($error) {
                if (function_exists('finfo_open')) {
                    if ($finfo = finfo_open(FILEINFO_MIME_TYPE)) {
                        if ($mime = finfo_file($finfo, $this->path)) {
                            try {
                                $this->mime = $this->mimeTypoFix($mime);
                            } catch (\ErrorException $e) {
                                error_log($e->getMessage());
                                $this->internalError = true;
                            }
                            finfo_close($finfo);
                            return;
                        }
                        finfo_close($finfo);
                    }
                }
            }
        }
        if (is_null($input)) {
            $input = 'application/octet-stream';
        }
        $this->mime = $input;
    }
protected function validMimeType ( $ input ) : void { if ( is_null ( $ this -> path ) ) { throw \ AWonderPHP \ FileWrapper \ NullPropertyException :: propertyIsNull ( 'path' ) ; } if ( ! is_null ( $ input ) ) { if ( ! is_string ( $ input ) ) { throw \ AWonderPHP \ FileWrapper \ TypeErrorException :: mimeWrongType ( $ input ) ; } $ input = trim ( strtolower ( $ input ) ) ; try { $ input = $ this -> mimeTypoFix ( $ input ) ; } catch ( \ ErrorException $ e ) { error_log ( $ e -> getMessage ( ) ) ; $ this -> internalError = true ; return ; } if ( in_array ( $ input , $ this -> validMime ) ) { $ this -> mime = $ input ; return ; } } // do what we can if ( $ input == "application/octet-stream" ) { $ input = null ; } $ error = false ; if ( ! is_null ( $ input ) ) { $ arr = explode ( '/' , $ input ) ; if ( count ( $ arr ) != 2 ) { $ error = true ; } elseif ( ! in_array ( $ arr [ 0 ] , array ( 'application' , 'audio' , 'font' , 'image' , 'multipart' , 'text' , 'video' ) ) ) { $ error = true ; } if ( $ error ) { if ( function_exists ( 'finfo_open' ) ) { if ( $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ) { if ( $ mime = finfo_file ( $ finfo , $ this -> path ) ) { try { $ this -> mime = $ this -> mimeTypoFix ( $ mime ) ; } catch ( \ ErrorException $ e ) { error_log ( $ e -> getMessage ( ) ) ; $ this -> internalError = true ; } finfo_close ( $ finfo ) ; return ; } finfo_close ( $ finfo ) ; } } } } if ( is_null ( $ input ) ) { $ input = 'application/octet-stream' ; } $ this -> mime = $ input ; }
Sets the MIME type the file will be served with. Does not compensate for all errors in
declared MIME types but will compensate for some.

@param null|string $input A MIME type.

@psalm-suppress RedundantConditionGivenDocblockType

@return void
Sets the MIME type the file will be served with . Does not compensate for all errors in declared MIME types but will compensate for some .