Expose getParamString on UrlEncodedFormContent.

This commit is contained in:
flash 2025-03-20 03:11:21 +00:00
parent fe6c62e1c0
commit 71435ba877
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
2 changed files with 14 additions and 2 deletions

View file

@ -1 +1 @@
0.2503.192123
0.2503.200311

View file

@ -1,7 +1,7 @@
<?php
// UrlEncodedFormContent.php
// Created: 2025-03-12
// Updated: 2025-03-15
// Updated: 2025-03-20
namespace Index\Http\Content;
@ -55,6 +55,18 @@ class UrlEncodedFormContent implements FormContent {
++$this->position;
}
/**
* Retrieves all post fields as a query string.
*
* @param ?bool $spacesAsPlus null to use the Index url encoder, other wise whether to represent spaces as a + instead of %20 with the legacy encoder.
* @return string Query string representation of post fields.
*/
public function getParamString(?bool $spacesAsPlus = null): string {
return $spacesAsPlus === null
? HttpUri::buildQueryString($this->params)
: http_build_query($this->params, '', '&', $spacesAsPlus ? PHP_QUERY_RFC1738 : PHP_QUERY_RFC3986);
}
/**
* Parses URL encoded form params in a stream.
*