Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 7 | public function render(mixed $data, mixed ...$args): string |
|
18 | { |
||
19 | 7 | assert($data instanceof Error); |
|
20 | |||
21 | 7 | $error = htmlspecialchars($data->error); |
|
22 | 7 | $body = "<h1>{$error}</h1>"; |
|
23 | |||
24 | 7 | if ($data->debug) { |
|
25 | 4 | $description = htmlspecialchars($data->description); |
|
26 | 4 | $body .= "<h2>{$description}</h2>"; |
|
27 | |||
28 | 4 | $traceback = str_replace( |
|
29 | 4 | ['<', '>', '"'], |
|
30 | 4 | ['<', '>', '"'], |
|
31 | 4 | $data->traceback |
|
32 | 4 | ); |
|
33 | 4 | $traceback = implode('<br>#', explode('#', $traceback)); |
|
34 | 4 | $body .= preg_replace('/^<br>/', '', $traceback); |
|
35 | } |
||
36 | |||
37 | 7 | return $body; |
|
38 | } |
||
45 |