mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
We have seen users that want to change the default behavior of parameter stringifier: * Change the depth level shown from an array. * Change the number of elements shown from an array. * Not add quotes to some parameters. Because of that, this commit will allow users to customize the parameter stringifier. This commit will also update the documentation to instruct how to customize it. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
33 lines
758 B
PHP
33 lines
758 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Respect/Validation.
|
|
*
|
|
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
|
|
*
|
|
* For the full copyright and license information, please view the "LICENSE.md"
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Message\Stringifier;
|
|
|
|
use Respect\Validation\Message\ParameterStringifier;
|
|
use function is_string;
|
|
use function Respect\Stringifier\stringify;
|
|
|
|
final class KeepOriginalStringName implements ParameterStringifier
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function stringify(string $name, $value): string
|
|
{
|
|
if ($name === 'name' && is_string($value)) {
|
|
return $value;
|
|
}
|
|
|
|
return stringify($value);
|
|
}
|
|
}
|