| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class HtmlErrorRenderer implements Renderer |
||
| 13 | { |
||
| 14 | 5 | public function __construct(protected Factory $factory) |
|
| 16 | 5 | } |
|
| 17 | |||
| 18 | 4 | public function render(mixed $data, mixed ...$args): string |
|
| 19 | { |
||
| 20 | 4 | assert(is_array($data)); |
|
| 21 | 4 | assert(isset($data['error'])); |
|
| 22 | 4 | assert($data['error'] instanceof Error); |
|
| 23 | 4 | $error = $data['error']; |
|
| 24 | |||
| 25 | 4 | $title = htmlspecialchars($error->error); |
|
| 26 | |||
| 27 | 4 | return sprintf( |
|
| 28 | 4 | '<!doctype html>' . |
|
| 29 | 4 | '<html lang="en">' . |
|
| 30 | 4 | '<head>' . |
|
| 31 | 4 | '<meta charset="utf-8">' . |
|
| 32 | 4 | '<meta name="viewport" content="width=device-width, initial-scale=1">' . |
|
| 33 | 4 | '<title>%s</title>' . |
|
| 34 | 4 | '</head>' . |
|
| 35 | 4 | '<body><h1>%s</h1></body></html>', |
|
| 36 | 4 | $title, |
|
| 37 | 4 | $title |
|
| 38 | 4 | ); |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | public function response(mixed $data, mixed ...$args): Response |
|
| 44 | } |
||
| 45 | } |
||
| 46 |