for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Validator;
final class ErrorMessage
{
private string $message = '';
private array $parameters = [];
private ErrorMessageFormatterInterface $formatter;
public function __construct(string $message, array $parameters = [])
$this->message = $message;
$this->parameters = $parameters;
$this->formatter = new ErrorMessageFormatter();
}
public function getMessage(): string
return $this->message;
public function getParameters(): array
return $this->parameters;
public function getFormattedMessage(?ErrorMessageFormatterInterface $formatter = null): string
$formatter = $formatter ?? $this->formatter;
return $formatter->format($this);
public function __toString(): string
return $this->getFormattedMessage();