| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | final class XmlRenderer extends ThrowableRenderer |
||
| 15 | { |
||
| 16 | public function render(Throwable $t, ServerRequestInterface $request = null): string |
||
| 17 | { |
||
| 18 | $out = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; |
||
| 19 | $out .= "<error>\n"; |
||
| 20 | $out .= $this->tag('message', 'An internal server error occurred'); |
||
| 21 | $out .= '</error>'; |
||
| 22 | return $out; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function renderVerbose(Throwable $t, ServerRequestInterface $request = null): string |
||
| 26 | { |
||
| 27 | $out = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; |
||
| 28 | $out .= "<error>\n"; |
||
| 29 | $out .= $this->tag('type', get_class($t)); |
||
| 30 | $out .= $this->tag('message', $this->cdata($t->getMessage())); |
||
| 31 | $out .= $this->tag('code', $this->cdata((string) $t->getCode())); |
||
| 32 | $out .= $this->tag('file', $t->getFile()); |
||
| 33 | $out .= $this->tag('line', (string) $t->getLine()); |
||
| 34 | $out .= $this->tag('trace', $t->getTraceAsString()); |
||
| 35 | $out .= '</error>'; |
||
| 36 | return $out; |
||
| 37 | } |
||
| 38 | |||
| 39 | private function tag(string $name, string $value): string |
||
| 40 | { |
||
| 41 | return "<$name>" . $value . "</$name>\n"; |
||
| 42 | } |
||
| 43 | |||
| 44 | private function cdata(string $value): string |
||
| 47 | } |
||
| 48 | } |
||
| 49 |