Get the format based in the extension.

@param string $file

@return string|null
505893
private function getFunctionName($prefix, $file, $suffix, $key = 0)
    {
        if (preg_match(self::getRegex(), strtolower($file), $matches)) {
            $format = self::$suffixes[$matches[1]];

            if (is_array($format)) {
                $format = $format[$key];
            }

            return sprintf('%s%s%s', $prefix, $format, $suffix);
        }
    }
1198301
protected function loader($file)
    {
        foreach ($this->folders as $folder)
        {
            foreach (FileLoader::extensions() as $ext)
            {
                try
                {
                    return FileLoader::load($folder . '/' . $file . '.' . $ext);
                }
                catch (\Throwable $throwable)
                {
                    // skip...
                }
            }
        }

        return null;
    }
796000
public static function read(string $file = ''): string
    {
        $result = false;
        $file = static::normalizePath($file);

        if (static::exists($file)) {
            $result = @\file_get_contents($file);
        }

        return $result;
    }
1141110
public function detectMimeType($file = null) {
		// Attempts to retrieve file info from FINFO
		// If FINFO functions are not available then try to retrieve MIME type from pre-defined MIMEs
		// If MIME type doesn't exist, then try (as a last resort) to use the (deprecated) mime_content_type function
		// If all else fails, just return application/octet-stream
		if (!function_exists('finfo_open')) {
			if (function_exists('mime_content_type')) {
				$type = mime_content_type($file);
				if (!empty($type)) {
					return $type;
				}
			}
			$extension = $this->_getExtension($file);
			$mimeType = $this->getMimeTypeByAlias($extension);
			if ($mimeType) {
				return $mimeType;
			}
			return 'application/octet-stream';
		}
		return $this->_detectMimeType($file);
	}
85240
public function getAbsolute($file) {
        if (is_file($file)) {
            return $file;
        }
        $path = $this->fullName.'/'.$file;
        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
        $absolutes = array();
        foreach ($parts as $part) {
            if ('.' == $part) continue;
            if ('..' == $part) {
                array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }
        return implode(DIRECTORY_SEPARATOR, $absolutes);
    }
806740
static public function getFileExt($file)
    {
        $s = strrchr($file, '.');
        if ($s === false)
        {
            return false;
        }
        return strtolower(trim(substr($s, 1)));
    }
1069890
public function parse($file)
    {
        $result = null;
        $this->hook->attach('help.render.before', $file, $result, $this);

        if (isset($result)) {
            return (string) $result;
        }

        $result = $this->markdown->render(file_get_contents($file));
        $this->hook->attach('help.render.after', $file, $result, $this);
        return (string) $result;
    }
573302
public function getExtension($file = "", $default = null)
    {

        $file = (empty($file) && isset($this->file)) ? $this->file : $file;

        if (empty($file)) {
            return $default;
        }

        //Determine the file extension
        return pathinfo($file, PATHINFO_EXTENSION);
    }
1314733
public function realpath($file)
    {
        $prefix = preg_quote($this->_prefix, '~');
        $file = preg_replace("~^{$prefix}~", '', $file);
        if (!$this->_hasVolume) {
            return $file;
        }
        if (preg_match('~^[A-Z]+:~', $file)) {
            return $file;
        }
        $file = ltrim($file, DS);
        $pos = strpos($file, DS);
        if ($pos !== false) {
            $file = substr_replace($file, ':' . DS, $pos, 1);
        }
        return $file;
    }
546179
private function getFileContents($file) {
    if (file_exists($file) === FALSE) {
      return NULL;
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return NULL;
    }

    return $contents;
  }
549580
protected function getMetaFilePath($file)
	{
		$parts = pathinfo($file);
		$metaFilename = sprintf($this->metaFileMask, $parts['basename']);
		return str_replace($parts['basename'], $metaFilename, $file);
	}
723159
protected function getExtension($file)
    {
        if (strpos($file, '.') !== false) {
            $tempExt = strtolower(substr($file, strrpos($file, '.') + 1, strlen($file) - strrpos($file, '.')));
            return strtolower(trim($tempExt,'/'));
        }
        return '';
    }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
783150
public function findFile($file, $ext = '')
    {
        $paths = clone $this->getPaths();

        $file = str_replace('.', '/', $file);

        $ext = $ext ? '.' . trim($ext, '.') : '';

        foreach ($paths as $path) {
            $filePath = $path . '/' . $file . $ext;

            if (is_file($filePath)) {
                return realpath($filePath);
            }
        }

        return null;
    }
422204
private function getFullPath(string $file = null): string
	{
		return $this->getBasePath() . $this->path . ($file !== null ? DIRECTORY_SEPARATOR . $file : '');
	}
217807
public function getFilePath($file): string
    {
        if (null === ($fileObj = $this->container->get('huh.utils.file')->getFileFromUuid($file))) {
            return '';
        }

        return $fileObj->path;
    }
229445
protected function getFileContents($file)
    {
        if ($file instanceof ModuleResource) {
            $path = $file->getPath();
        } else {
            $path = Director::baseFolder() . '/' . $file;
        }
        if (!file_exists($path)) {
            return null;
        }
        $content = file_get_contents($path);

        // Remove UTF-8 BOM
        if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf)) {
            $content = substr($content, 3);
        }

        return $content;
    }