app/Config/Mimes.php
public static function guessExtensionFromType(string $type, ?string $proposed_extension = null)
	{
		$type = trim(strtolower($type), '. ');

		$proposed_extension = trim(strtolower($proposed_extension));

		if (! is_null($proposed_extension) && array_key_exists($proposed_extension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposed_extension]) ? [static::$mimes[$proposed_extension]] : static::$mimes[$proposed_extension]))
		{
			return $proposed_extension;
		}

		foreach (static::$mimes as $ext => $types)
		{
			if (is_string($types) && $types === $type)
			{
				return $ext;
			}
			else if (is_array($types) && in_array($type, $types))
			{
				return $ext;
			}
		}

		return null;
	}
public static function guessExtensionFromType(string $type, ?string $proposed_extension = null)
	{
		$type = trim(strtolower($type), '. ');

		$proposed_extension = trim(strtolower($proposed_extension));

		if (! is_null($proposed_extension) && array_key_exists($proposed_extension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposed_extension]) ? [static::$mimes[$proposed_extension]] : static::$mimes[$proposed_extension]))
		{
			return $proposed_extension;
		}

		foreach (static::$mimes as $ext => $types)
		{
			if (is_string($types) && $types === $type)
			{
				return $ext;
			}
			else if (is_array($types) && in_array($type, $types))
			{
				return $ext;
			}
		}

		return null;
	}
Attempts to determine the best file extension for a given mime type.

@param string $type
@param string $proposed_extension - default extension (in case there is more than one with the same mime type)

@return string|null The extension determined, or null if unable to match.