Total Complexity | 10 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 86.96% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class ErrorMessage |
||
8 | { |
||
9 | private string $message = ''; |
||
10 | private array $parameters = []; |
||
11 | |||
12 | 172 | public function __construct(string $message, array $parameters = []) |
|
13 | { |
||
14 | 172 | $this->message = $message; |
|
15 | 172 | $this->parameters = $parameters; |
|
16 | 172 | } |
|
17 | |||
18 | 1 | public function getMessage(): string |
|
19 | { |
||
20 | 1 | return $this->message; |
|
21 | } |
||
22 | |||
23 | 1 | public function getParameters(): array |
|
24 | { |
||
25 | 1 | return $this->parameters; |
|
26 | } |
||
27 | |||
28 | 67 | public function getFormattedMessage(): string |
|
29 | { |
||
30 | 67 | return $this->format($this->message, $this->parameters); |
|
31 | } |
||
32 | |||
33 | 66 | public function __toString(): string |
|
34 | { |
||
35 | 66 | return $this->getFormattedMessage(); |
|
36 | } |
||
37 | |||
38 | 67 | private function format(string $message, array $params = []): string |
|
52 | } |
||
53 | } |
||
54 |