public function getParser($format)
    {
        static $defaultParsers = [
            self::FORMAT_JSON => 'yii\httpclient\JsonParser',
            self::FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_XML => 'yii\httpclient\XmlParser',
        ];

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

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

        return $this->parsers[$format];
    }
public function getParser($format)
    {
        static $defaultParsers = [
            self::FORMAT_JSON => 'yii\httpclient\JsonParser',
            self::FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_XML => 'yii\httpclient\XmlParser',
        ];

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

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

        return $this->parsers[$format];
    }
public function getParser ( $ format ) { static $ defaultParsers = [ self :: FORMAT_JSON => 'yii\httpclient\JsonParser' , self :: FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser' , self :: FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser' , self :: FORMAT_XML => 'yii\httpclient\XmlParser' , ] ; if ( ! isset ( $ this -> parsers [ $ format ] ) ) { if ( ! isset ( $ defaultParsers [ $ format ] ) ) { throw new InvalidParamException ( "Unrecognized format '{$format}'" ) ; } $ this -> parsers [ $ format ] = $ defaultParsers [ $ format ] ; } if ( ! is_object ( $ this -> parsers [ $ format ] ) ) { $ this -> parsers [ $ format ] = Yii :: createObject ( $ this -> parsers [ $ format ] ) ; } return $ this -> parsers [ $ format ] ; }
Returns HTTP message parser instance for the specified format.
@param string $format format name
@return ParserInterface parser instance.
@throws InvalidParamException on invalid format name.
@throws \yii\base\InvalidConfigException
Returns HTTP message parser instance for the specified format .