Return mime type of a passed file in optimized mode.
@param string $fullPathFile
@return string
495138
public static function getMimeType(string $fullPathFile) : string
    {
        $mime_types = self::$arrMimeType;
        $ext = strtolower(self::getFilenameExtension($fullPathFile));
        if (array_key_exists($ext, $mime_types)) {
            return $mime_types[$ext];
        }
        $mimetype = self::getMimeTypeByMimeContentType($fullPathFile);
        if (isNotNullOrEmpty($mimetype)) {
            return $mimetype;
        }
        $mimetype = self::getMimeTypeByFinfo($fullPathFile);
        if (isNotNullOrEmpty($mimetype)) {
            return $mimetype;
        }
        return 'application/octet-stream';
    }
582965
public function getMimeType()
    {
        if (empty($this->mimeType)) {
            $resource = finfo_open(FILEINFO_MIME_TYPE);
            $this->mimeType = finfo_file($resource, $this->getRealPath());
        }

        return $this->mimeType;
    }
237375
private static function get_mime_type($extension) {
		$mime_type = '';
		switch ($extension) {
			case 'htm' :
			case 'html': $mime_type = 'text/html';
			             break;

			case 'css' : $mime_type = 'text/css';
			             break;

			case 'ico' : $mime_type = 'image/x-icon';
			             break;

			case 'js'  : $mime_type = 'text/javascript';
			             break;

			case 'png' : $mime_type = 'image/png';
			             break;

			case 'gif' : $mime_type = 'image/gif';
			             break;

			case 'jpg' :
			case 'jpeg': $mime_type = 'image/jpeg';
			             break;

			case 'pdf' : $mime_type = 'application/pdf';
						 break;

			case 'txt' : $mime_type = 'text/plain';
						 break;

			case 'svg' : $mime_type = 'image/svg+xml';
						 break;

			default    : $mime_type = 'application/octet-stream';
		}

		return $mime_type;
	}
339474
public function getMimeType($extension)
    {
        if (isset($this->mimeTypes['.'.strtolower($extension)])) {
            return $this->mimeTypes['.'.strtolower($extension)];
        }

        return 'text/plain';
    }
1351023
protected static function _getFile($fullPath) {
        $file = '';
        if (preg_match('/\/(_[A-Z].[A-Za-z]+)\.php$/', $fullPath, $matches)) {
            $file = isset($matches) && isset($matches[1]) ? $matches[1] : $file;
            self::$numFileLogs = 0;
        } else {
            switch (self::$numFileLogs) {
                case 0:
                    self::_doLog('Unable to get filename for: ' . $fullPath);
                    break;

                case 1:
                    self::_doLog('MULTIPLE ERRORS ENCOUNTERED GETTING FILE NAMES (no more will be logged): ' . $fullPath);
                    break;

                default:
                    break;
            }
            self::$numFileLogs++;
        }
        return $file;
    }
425803
static String _getMimeType(String uriOrPath) {
        String mime = MIME_MAP.get(__getExtension(uriOrPath));

        if (mime == null) {
            mime = DEFAULT_MIME;
        }

        return mime;
    }
1312839
protected static function getFileImprint ($fullPath) {
		$fileChecking = self::$globalOptions['fileChecking'];
		if ($fileChecking == 'filemtime') {
			return filemtime($fullPath);
		} else {
			return (string) call_user_func($fileChecking, $fullPath);
		}
	}
636141
static public function getMimeType($contentType, $filename=null)
    {
        if ($contentType = strtolower($contentType)) {
            if (strpos($contentType, '/') !== false) {
                $mimeTypes = array_keys(self::$mime_types, $contentType);
                $ext = $filename ? pathinfo($filename, PATHINFO_EXTENSION) : null;
                
                if (count($mimeTypes) === 1) {
                    return $mimeTypes[0];
                } elseif (count($mimeTypes) > 1) {
                    return $ext && in_array($ext, $mimeTypes) ? $ext : $mimeTypes[0];
                } else {
                    return $ext ? static::getMimeType($ext) : null;
                }
            } else {
                $ext = pathinfo($contentType, PATHINFO_EXTENSION);
                if (isset(static::$mime_types[$ext])) {
                    return $ext;
                }
            }
        } elseif ($filename) {
            return static::getMimeType($filename);
        }
        
        return null;
    }
1308842
public static function getMimeType($filename)
	{
		$mime_types = static::getMimeTypes();
		
		$extension = pathinfo($filename, PATHINFO_EXTENSION);
    	$extension = strtolower($extension);
    	
		if (array_key_exists($extension, $mime_types)) {
            return $mime_types[$extension];
        } elseif (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME);
            $mimetype = finfo_file($finfo, $filename);
            finfo_close($finfo);
            return $mimetype;
        } 
        return 'application/octet-stream';
	}
56519
public function mimeType($path)
    {
        if ($this->isDirectory($path)) {
            return static::$directoryMimetype;
        }
        return $this->mimeTypes->typeOfFile($path);
    }
776519
public function getName($full = false)
    {
        if ( ! $full ) {
            return $this->templateName;
        }
        $filename = $this->directory ? $this->directory . '/' . $this->templateName : $this->templateName;

        return str_replace('//' , '/' , $filename);
    }
62377
public function getMimeType($mime)
    {
        if (isset($this->mimes[$mime]))
        {
            return $this->mimes[$mime];
        }
        else
        {
            return false;
        }
    }
758459
public function get_mime($file){
        $type = $this->get_content_type($file);
        if( $type ){
            $type = array_map('trim', explode(';', $type));
            return $type[0];
        }else{
            return '';
        }
    }
485057
public static function mimetypeFile ($path)
		{
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			if ($finfo)
			{
				$info = finfo_file($finfo, $path);
				finfo_close($finfo);

				return $info;
			}

			return null;
		}
468514
protected function get_stripped_file_contents($fullpath) {

        $source = file_get_contents($fullpath);
        $tokens = token_get_all($source);
        $output = '';
        $doprocess = false;
        foreach ($tokens as $token) {
            if (is_string($token)) {
                // Simple one character token.
                $id = -1;
                $text = $token;
            } else {
                // Token array.
                list($id, $text) = $token;
            }
            switch ($id) {
                case T_WHITESPACE:
                case T_COMMENT:
                case T_ML_COMMENT:
                case T_DOC_COMMENT:
                    // Ignore whitespaces, inline comments, multiline comments and docblocks.
                    break;
                case T_OPEN_TAG:
                    // Start processing.
                    $doprocess = true;
                    break;
                case T_CLOSE_TAG:
                    // Stop processing.
                    $doprocess = false;
                    break;
                default:
                    // Anything else is within PHP tags, return it as is.
                    if ($doprocess) {
                        $output .= $text;
                        if ($text === 'function') {
                            // Explicitly keep the whitespace that would be ignored.
                            $output .= ' ';
                        }
                    }
                    break;
            }
        }

        return $output;
    }
927095
public static function saveFile(string $fullPath, string $content)
    {
        if (file_exists($fullPath)) {
            $arrFilePath = explode(DIRECTORY_SEPARATOR, $fullPath);
            $fileName = array_pop($arrFilePath);
            $newFileName = self::iterateFileName($fileName);
            $arrFilePath[] = $newFileName;
            $newFullPath = implode(DIRECTORY_SEPARATOR, $arrFilePath);
            return self::saveFile($newFullPath, $content);
        }
        $file = fopen($fullPath, "w");
        fputs($file, $content);
        fclose($file);
        chmod($fullPath, 0775);
        return $fullPath;
    }
283442
public function getMimetype($path)
    {
        $file_info = $this->getMetadata($path);
        return $file_info != false && !empty($file_info['content-type']) ? [ 'mimetype' => $file_info['content-type'] ] : false;
    }