Zend\Mvc\Controller\AbstractRestfulController::processBodyContent PHP Method

processBodyContent() protected method

If the content-type indicates a JSON payload, the payload is immediately decoded and the data returned. Otherwise, the data is passed to parse_str(). If that function returns a single-member array with a empty value, the method assumes that we have non-urlencoded content and returns the raw content; otherwise, the array created is returned.
protected processBodyContent ( mixed $request ) : object | string | array
$request mixed
return object | string | array
    protected function processBodyContent($request)
    {
        $content = $request->getContent();
        // JSON content? decode and return it.
        if ($this->requestHasContentType($request, self::CONTENT_TYPE_JSON)) {
            return $this->jsonDecode($request->getContent());
        }
        parse_str($content, $parsedParams);
        // If parse_str fails to decode, or we have a single element with empty value
        if (!is_array($parsedParams) || empty($parsedParams) || 1 == count($parsedParams) && '' === reset($parsedParams)) {
            return $content;
        }
        return $parsedParams;
    }