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];
    }
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];
    }
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 ] ; }
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
Returns HTTP message formatter instance for the specified format .