app/Config/Format.php
public function getFormatter(string $mime)
	{
		if (! array_key_exists($mime, $this->formatters))
		{
			throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime);
		}

		$class = $this->formatters[$mime];

		if (! class_exists($class))
		{
			throw new \BadMethodCallException($class . ' is not a valid Formatter.');
		}

		return new $class();
	}
public function getFormatter(string $mime)
	{
		if (! array_key_exists($mime, $this->formatters))
		{
			throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime);
		}

		$class = $this->formatters[$mime];

		if (! class_exists($class))
		{
			throw new \BadMethodCallException($class . ' is not a valid Formatter.');
		}

		return new $class();
	}
A Factory method to return the appropriate formatter for the given mime type.

@param string $mime

@return \CodeIgniter\Format\FormatterInterface