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);
    }
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);
    }
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 ) ; }
Inserts the given values into the chronological placeholders

@param array ...$replacements Collection of items to insert into the string

@return $this
Inserts the given values into the chronological placeholders