mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 16:52:16 +02:00
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:
parent
543b97309a
commit
fb322df1da
|
@ -11,7 +11,6 @@ namespace Respect\Validation\Message;
|
||||||
|
|
||||||
use function call_user_func;
|
use function call_user_func;
|
||||||
use function preg_replace_callback;
|
use function preg_replace_callback;
|
||||||
use function Respect\Stringifier\stringify;
|
|
||||||
|
|
||||||
final class Formatter
|
final class Formatter
|
||||||
{
|
{
|
||||||
|
@ -37,7 +36,7 @@ final class Formatter
|
||||||
*/
|
*/
|
||||||
public function format(string $template, $input, array $parameters): string
|
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(
|
return preg_replace_callback(
|
||||||
'/{{(\w+)}}/',
|
'/{{(\w+)}}/',
|
||||||
|
|
Loading…
Reference in a new issue