Nathanmac\Utilities\Parser\Parser::getFormatClass PHP Method

getFormatClass() public method

Autodetect the payload data type using content-type value.
public getFormatClass ( $format = '' ) : string
return string Return the name of the formatter class.
    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';
    }