Returns HTTP message formatter instance for the specified format.
@param string $format format name.
@return FormatterInterface formatter instance.
@throws InvalidParamException on invalid format name.
@throws \yii\base\InvalidConfigException
358892
public function getFormatter($format)
    {
        static $defaultFormatters = [
            self::FORMAT_JSON => 'yii\httpclient\JsonFormatter',
            self::FORMAT_URLENCODED => [
                'class' => 'yii\httpclient\UrlEncodedFormatter',
                'encodingType' => PHP_QUERY_RFC1738
            ],
            self::FORMAT_RAW_URLENCODED => [
                'class' => 'yii\httpclient\UrlEncodedFormatter',
                'encodingType' => PHP_QUERY_RFC3986
            ],
            self::FORMAT_XML => 'yii\httpclient\XmlFormatter',
            self::FORMAT_CURL => 'yii\httpclient\CurlFormatter',
        ];

        if (!isset($this->formatters[$format])) {
            if (!isset($defaultFormatters[$format])) {
                throw new InvalidParamException("Unrecognized format '{$format}'");
            }
            $this->formatters[$format] = $defaultFormatters[$format];
        }

        if (!is_object($this->formatters[$format])) {
            $this->formatters[$format] = Yii::createObject($this->formatters[$format]);
        }

        return $this->formatters[$format];
    }
948456
public function get($format)
    {
        if (!array_key_exists($format, $this->encoders)) {
            throw new \RuntimeException(
                sprintf('The expression encoder for "%s" formatting was not found.', $format)
            );
        }

        return $this->encoders[$format];
    }
942612
public function format($format = null)
    {
        if ($format !== null) {
            $this->format = $format;
        }

        return $this->format;
    }
336957
public function getFormatClass($format = '')
    {
        if ( ! empty($format)) {
            return $this->processContentType($format);
        }

        if (isset($_SERVER['CONTENT_TYPE'])) {
            $type = $this->processContentType($_SERVER['CONTENT_TYPE']);
            if ($type !== false) {
                return $type;
            }
        }

        if (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
            $type = $this->processContentType($_SERVER['HTTP_CONTENT_TYPE']);
            if ($type !== false) {
                return $type;
            }
        }

        return 'Nathanmac\Utilities\Parser\Formats\JSON';
    }
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;
    }
343550
public function format($format)
    {
        $parsedFormat = static::parseFormat($format);

        if (is_null($parsedFormat)) {
            throw NumberFormatException::invalid($format);
        }

        return $this->lib->format(
            $this->getPhoneNumberInstance(),
            $parsedFormat
        );
    }
1185995
public function setFormat(FormatInterface $format)
    {
        $this->formatId = $format->getName();

        return parent::setFormat($format);
    }
640913
public function format($format)
    {
        try {
            return $this->getDateObject()->format($format);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_FORMAT, [$format]);
        }
    }
996501
public function format(int $format) : string
    {
        return PhoneNumberUtil::getInstance()->format($this->phoneNumber, $format);
    }
1079579
protected function getParser($format)
    {
        if (!isset($this->formatFilePaths[$format])) {
            throw new FormatImporterNotFoundException($format);
        }

        return $this->formatFilePaths[$format];
    }
64607
public function setFormat($format)
    {
        if ($format !== self::FORMAT_BINARY && $format !== self::FORMAT_TEXT) {
            throw new InvalidArgumentException("Invalid message format");
        }

        $this->format = $format;
    }
205288
public function getFormatInstance($format = null)
    {
        $format = $format ?: $this->format;

        if (!($format instanceof FormatInterface)) {
            if (!isset($this->formats[$format])) {
                $event = new NewFormatEvent($this, new $format($this));
                $this->trigger($event);
                $this->formats[$format] = $event->getFormat();
            }

            $format = $this->formats[$format];
        }

        return $format;
    }
546496
public function getApiURL($format = null)
    {
        $apiUrl = str_replace(['.'.$this->format, '?limit=0'], '', $this->apiURL);
        return $apiUrl.(empty($format) ? '' : '.'.$format );
    }
550213
public function export($format = FilledFormExportFormat::JSON)
    {
        if (! $format instanceof FilledFormExportFormat) {
            $format = new FilledFormExportFormat($format);
        }

        return static::query($this->client, [$this->filled_form_id, self::EXPORT], ['format' => $format->getValue()]);
    }
602509
public function setFileFormat($format)
    {
        if (!in_array($format, array(self::FORMAT_BMP, self::FORMAT_TGA))) {
            throw new \InvalidArgumentException('Invalid file format: '.$format, ErrorCodes::INVALID_VALUE);
        }
        $this->setArgument('f', $format);
        return $this;
    }
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');
    }
140753
private function headersFromFormat($format)
	{
		$type = gettype($format);
		if($type === 'array')
		{
			$headers = $format;
		}
		else if($type === 'string')
		{
			$headers = array();
			switch ($format) 
			{
				case 'json':
					$contentType = 'application/json';
					break;
				case 'jsonp':
					$contentType = 'application/javascript';
					break;
				default:
					$contentType = 'text/plain';
					break;
			}
			$headers['Content-Type'] = $contentType;
		}
		return $headers;
	}