Returns image formatted for given format name or FormatInterface object.

@param string|FormatInterface $format

@return FormattedImageInterface|null
177096
public function getFormattedImage($format)
    {
        $formatName = $format instanceof FormatInterface
            ? $format->getName()
            : $format
        ;

        return $this->formattedImages
            ->filter(function (FormattedImageInterface $formattedImage) use ($formatName) {
                return ($format = $formattedImage->getFormat())
                    && $format->getName() == $formatName
                ;
            })
            ->first() ?: null // first() returns "false" if collection empty
        ;
    }
54488
public function getPiwikVersion($format = null)
    {
        $options = $this->getOptions($format)
            ->usePeriod(false)
            ->useSiteId(false);

        return $this->request->send($options);
    }
1292748
public function getParser(FormatInterface $format)
    {
        switch ($format->getType()) {
            case 'csv':
                if ($format instanceof CsvFormatInterface) {
                    return new CsvParser($format);
                } else {
                    throw new InvalidArgumentException(
                        "Format indicates it is csv but does not implement CsvFormatInterface"
                    );
                }

            // fallthrough
            case 'json':
                if ($format instanceof JsonFormatInterface) {
                    return new JsonParser($format);
                } else {
                    throw new InvalidArgumentexception(
                        "Format indicates it is json but does not implement JsonFormatInterface"
                    );
                }

            // fallthrough
            default:
                throw new InvalidArgumentException("Supplied format: {$format->getType()} is unknown");
        }
    }
367
protected function getRendererForFormat(string $format)
    {
        if (!isset($this->renderers[$format])) {
            throw new InvalidRendererException('No renders found for the given format: '.$format);
        }

        return $this->renderers[$format];
    }
941196
public static function getTemplate($template, $format = 'html5')
	{
		$templates = static::getTemplates($template, $format = 'html5');

		return isset($templates[0]) ? $templates[0] : null;
	}
879233
protected function normalizeFormat($format)
    {
        $format = strtolower(trim((string) $format));
        if ($format === 'jpg') {
            $format = static::FORMAT_JPEG;
        }

        return $format;
    }
1152229
private function getMimeType($format)
    {
        $format = $this->normalizeFormat($format);

        static $mimeTypes = array(
            'jpeg' => 'image/jpeg',
            'gif'  => 'image/gif',
            'png'  => 'image/png',
            'wbmp' => 'image/vnd.wap.wbmp',
            'xbm'  => 'image/xbm',
        );

        if (!isset($mimeTypes[$format])) {
            throw new \RuntimeException('Invalid format');
        }

        return $mimeTypes[$format];
    }
1131161
public function format($data, $format)
    {
        // Case handing. ex. json => Json
        $format = ucfirst(strtolower($format));
        $formatFunc = "format" . $format;
        // Use formatter if exists
        if (method_exists($this, $formatFunc)) {
            
            $data = $this->{$formatFunc}($data);
        } 
        elseif (is_array($data)) {
            // Use JSON while the Formatter not found and the data is array
            $data = $this->formatJson($data);
        }

        return $data;
    }
905167
public function getDateTimeFormat(string $format='Y-m-d H:i:s')
    {
        $this->setDateTimeZone()->setDateTime();

        return $this->dateTime->format($format);
    }
429476
public function getEncoder($format)
    {
        if (!$this->supports($format)) {
            throw new \InvalidArgumentException(sprintf("Format '%s' is not supported by ContainerDecoderProvider.", $format));
        }

        return $this->container->get($this->encoders[$format]);
    }
1243211
public static function getMimeTypes($format)
    {
        if (null === static::$formats) {
            static::initializeFormats();
        }

        return isset(static::$formats[$format]) ? static::$formats[$format] : [];
    }
759755
public function getFormatMimeType($format)
    {
        $format = $this->normalizeFormat($format);
        $result = '';
        switch ($format) {
            case static::FORMAT_PNG:
            case static::FORMAT_JPEG:
            case static::FORMAT_GIF:
            case static::FORMAT_XBM:
                $result = 'image/' . $format;
                break;
            case static::FORMAT_WBMP:
                $result = 'image/vnd.wap.wbmp';
                break;
        }

        return $result;
    }
360472
public function getRenderer(string $format): ResultsRendererInterface
    {
        if ($format === self::FORMAT_CSV) {
            return new CsvResultsRenderer;
        }

        if ($format === self::FORMAT_JSON) {
            return new JsonResultsRenderer;
        }

        if ($format === self::FORMAT_TEXT) {
            return new ConsoleResultsRenderer;
        }

        throw new InvalidArgumentException('Invalid output format provided');
    }
927008
private function ffprobeFormat($format)
	{
		$this->ffprobe();

		if (count($this->formats) > 0)
		{
			$args = func_get_args();

			foreach ($args as $arg)
			{
				if (in_array($arg, $this->formats))
				{
					return true;
				}
			}

			return null;
		}

		return false;
	}
1014072
public function setFormat($format = null)
    {
        if ( ! is_null($format)) {
            self::checkFormat($format);
            $this->format = $format;
        }

        return $this;
    }
1198378
public function setFormat(string $format = \null)
    {
        $validValues = ['png', 'jpg', 'webp'];

        if (\null !== $format && !\in_array($format, $validValues, \true)) {
            throw new \InvalidArgumentException(\sprintf(
                'Unknown format "%s" given. Expected "%s" or null.',
                $format,
                \implode(', ', $validValues)
            ));
        }

        $this->format = $format;

        return $this;
    }
512619
public static function getPort(ServerRequestInterface $request, string $format): string
    {
        switch ($format) {
            case 'canonical':
            case 'local':
                return (string) ($request->getUri()->getPort()
                    ?: ('https' === $request->getUri()->getScheme() ? 443 : 80));
            default:
                return '-';
        }
    }