Use "ParameterStringifier" to stringify input

The idea of the "ParameterStringifier" is to convert any value to a
string. However, we use the "stringify" function directly when
converting the input into a string. That defies the purpose of the
ParameterStringifier, as it gives the "Formatter" two ways of converting
a value into a string.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2024-03-11 20:01:47 +01:00
parent 543b97309a
commit fb322df1da
No known key found for this signature in database
GPG key ID: 221E9281655813A6

View file

@ -11,7 +11,6 @@ namespace Respect\Validation\Message;
use function call_user_func;
use function preg_replace_callback;
use function Respect\Stringifier\stringify;
final class Formatter
{
@ -37,7 +36,7 @@ final class Formatter
*/
public function format(string $template, $input, array $parameters): string
{
$parameters['name'] = $parameters['name'] ?? stringify($input);
$parameters['name'] = $parameters['name'] ?? $this->parameterStringifier->stringify('input', $input);
return preg_replace_callback(
'/{{(\w+)}}/',