mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 01:33:11 +08:00
Extracted function to render arrays from inside ValidationException
This commit is contained in:
@@ -11,9 +11,7 @@ use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
use function array_keys;
|
||||
use function Functional\reduce_left;
|
||||
use function is_array;
|
||||
use function print_r;
|
||||
use function Shlinkio\Shlink\Core\arrayToString;
|
||||
use function sprintf;
|
||||
|
||||
use const PHP_EOL;
|
||||
@@ -60,19 +58,10 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
|
||||
$this->getMessage(),
|
||||
$this->getFile(),
|
||||
$this->getLine(),
|
||||
$this->invalidElementsToString(),
|
||||
arrayToString($this->getInvalidElements()),
|
||||
PHP_EOL,
|
||||
PHP_EOL,
|
||||
$this->getTraceAsString(),
|
||||
);
|
||||
}
|
||||
|
||||
private function invalidElementsToString(): string
|
||||
{
|
||||
return reduce_left($this->getInvalidElements(), fn ($messages, string $name, $_, string $acc) => $acc . sprintf(
|
||||
"\n '%s' => %s",
|
||||
$name,
|
||||
is_array($messages) ? print_r($messages, true) : $messages,
|
||||
), '');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user