protected function getContentTypeHeader(Request $request): ContentType
	{
		$headerName = 'Content-Type';
		if (!$request->hasHeader($headerName))
		{
			throw new Exception\BadRequest('Content-Type header should be declared');
		}
		if (count($request->getHeader($headerName)) > 1)
		{
			throw new Exception\BadRequest('Multiple Content-Type headers are not allowed');
		}
		try
		{
			return ContentType::fromString($headerName . ': ' . $request->getHeaderLine($headerName));
		}
		catch (\Exception $e)
		{
			throw new Exception\BadRequest('Invalid Content-Type header', $e);
		}
	}
protected function getContentTypeHeader(Request $request): ContentType
	{
		$headerName = 'Content-Type';
		if (!$request->hasHeader($headerName))
		{
			throw new Exception\BadRequest('Content-Type header should be declared');
		}
		if (count($request->getHeader($headerName)) > 1)
		{
			throw new Exception\BadRequest('Multiple Content-Type headers are not allowed');
		}
		try
		{
			return ContentType::fromString($headerName . ': ' . $request->getHeaderLine($headerName));
		}
		catch (\Exception $e)
		{
			throw new Exception\BadRequest('Invalid Content-Type header', $e);
		}
	}
protected function getContentTypeHeader ( Request $ request ) : ContentType { $ headerName = 'Content-Type' ; if ( ! $ request -> hasHeader ( $ headerName ) ) { throw new Exception \ BadRequest ( 'Content-Type header should be declared' ) ; } if ( count ( $ request -> getHeader ( $ headerName ) ) > 1 ) { throw new Exception \ BadRequest ( 'Multiple Content-Type headers are not allowed' ) ; } try { return ContentType :: fromString ( $ headerName . ': ' . $ request -> getHeaderLine ( $ headerName ) ) ; } catch ( \ Exception $ e ) { throw new Exception \ BadRequest ( 'Invalid Content-Type header' , $ e ) ; } }
Makes ContentType header object from PSR-7 request
@param Request $request
@return ContentType
@throws Exception\BadRequest
Makes ContentType header object from PSR - 7 request