public function format(...$replacements): Utility
    {
        $string = $this->string;

        foreach ($replacements as $index => $value) {
            if (!is_scalar($value) || (is_object($value) && !method_exists($value, '__toString'))) {
                $type = is_object($value) ? get_class($value) : gettype($value);
                throw new InvalidFormatArgumentException(
                    sprintf('Placeholder %s could not convert type %s to a string', $index, $type)
                );
            }

            $string = str_replace('{' . $index . '}', $value, $string);
        }

        return new static($string, $this->encoding);
    }