src/Extension/Core/DataTransformer/ValueFormatTransformer.php
public function transform($value)
    {
        if (is_array($value) && null === $this->glue && null === $this->format) {
            throw new TransformationFailedException(
                sprintf('At least "glue" or "format" option must be set when the end value is an array.')
            );
        }

        if (null === $this->format) {
            // Glue is required to be set at this point, so no need for further checking.
            if (is_array($value)) {
                return implode($this->glue, $value);
            }

            return (string) $value;
        }

        if (!is_array($value)) {
            $format = $this->format;

            if (is_callable($format)) {
                return $format($value);
            }

            return sprintf($format, $value);
        }

        return $this->formatValue($value, $this->format, $this->glue);
    }
public function transform($value)
    {
        if (is_array($value) && null === $this->glue && null === $this->format) {
            throw new TransformationFailedException(
                sprintf('At least "glue" or "format" option must be set when the end value is an array.')
            );
        }

        if (null === $this->format) {
            // Glue is required to be set at this point, so no need for further checking.
            if (is_array($value)) {
                return implode($this->glue, $value);
            }

            return (string) $value;
        }

        if (!is_array($value)) {
            $format = $this->format;

            if (is_callable($format)) {
                return $format($value);
            }

            return sprintf($format, $value);
        }

        return $this->formatValue($value, $this->format, $this->glue);
    }
{@inheritdoc}