yii\httpclient\Response::detectFormatByContent PHP Method

detectFormatByContent() protected method

Detects response format from raw content.
protected detectFormatByContent ( string $content ) : null | string
$content string raw response content.
return null | string format name, 'null' - if detection failed.
    protected function detectFormatByContent($content)
    {
        if (preg_match('/^\\{.*\\}$/is', $content)) {
            return Client::FORMAT_JSON;
        }
        if (preg_match('/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/', $content)) {
            return Client::FORMAT_URLENCODED;
        }
        if (preg_match('/^<.*>$/s', $content)) {
            return Client::FORMAT_XML;
        }
        return null;
    }