Templating/Helper/Format/FormatHelper.php
public function format($value, $format = null, array $options = [])
    {
        if (null === $format) {
            $format = $this->guessFormat($value);
        }

        if (!empty($options['template'])) {
            return $this->container->get('templating')->render(
                $options['template'],
                ['value' => $value, 'options' => $options, 'format' => $format] + $options
            );
        }

        if (!isset($this->formatters[$format])) {
            throw new \InvalidArgumentException(\sprintf('Formatter "%s" not found', $format));
        }

        return $this->formatters[$format]->format($value, $format, $options);
    }
public function format($value, $format = null, array $options = [])
    {
        if (null === $format) {
            $format = $this->guessFormat($value);
        }

        if (!empty($options['template'])) {
            return $this->container->get('templating')->render(
                $options['template'],
                ['value' => $value, 'options' => $options, 'format' => $format] + $options
            );
        }

        if (!isset($this->formatters[$format])) {
            throw new \InvalidArgumentException(\sprintf('Formatter "%s" not found', $format));
        }

        return $this->formatters[$format]->format($value, $format, $options);
    }
@param mixed  $value
@param string $format
@param array  $options

@throws \InvalidArgumentException if the formatter doesn't exist

@return string|null