| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class ErrorMessage |
||
| 8 | { |
||
| 9 | private string $message = ''; |
||
| 10 | private array $parameters = []; |
||
| 11 | private ErrorMessageFormatterInterface $formatter; |
||
| 12 | |||
| 13 | 177 | public function __construct(string $message, array $parameters = []) |
|
| 14 | { |
||
| 15 | 177 | $this->message = $message; |
|
| 16 | 177 | $this->parameters = $parameters; |
|
| 17 | 177 | $this->formatter = new ErrorMessageFormatter(); |
|
| 18 | 177 | } |
|
| 19 | |||
| 20 | 83 | public function getMessage(): string |
|
| 21 | { |
||
| 22 | 83 | return $this->message; |
|
| 23 | } |
||
| 24 | |||
| 25 | 83 | public function getParameters(): array |
|
| 28 | } |
||
| 29 | |||
| 30 | 83 | public function getFormattedMessage(?ErrorMessageFormatterInterface $formatter = null): string |
|
| 31 | { |
||
| 32 | 83 | $formatter = $formatter ?? $this->formatter; |
|
| 33 | 83 | return $formatter->format($this); |
|
| 34 | } |
||
| 35 | |||
| 36 | 3 | public function __toString(): string |
|
| 39 | } |
||
| 40 | } |
||
| 41 |