| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 13 | final class ErrorData implements Stringable |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param string $content The content to use as response body. |
||
| 17 | * @param array<string, string|string[]> $headers The headers to add to the response. |
||
| 18 | */ |
||
| 19 | 29 | public function __construct( |
|
| 20 | private string $content, |
||
| 21 | private array $headers = [], |
||
| 22 | ) { |
||
| 23 | 29 | } |
|
| 24 | |||
| 25 | /** |
||
| 26 | * Returns a content to use as response body. |
||
| 27 | * |
||
| 28 | * @return string The content to use as response body. |
||
| 29 | */ |
||
| 30 | 13 | public function __toString(): string |
|
| 31 | { |
||
| 32 | 13 | return $this->content; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Returns a response with error data. |
||
| 37 | * |
||
| 38 | * @param ResponseInterface $response The response for setting error data. |
||
| 39 | * |
||
| 40 | * @return ResponseInterface The response with error data. |
||
| 41 | */ |
||
| 42 | 12 | public function addToResponse(ResponseInterface $response): ResponseInterface |
|
| 52 | } |
||
| 53 | } |
||
| 54 |