| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class XmlRenderer implements ErrorRendererInterface |
||
| 8 | { |
||
| 9 | public function render(\Throwable $e): string |
||
| 10 | { |
||
| 11 | $out = '<' . '?xml version="1.0" encoding="UTF-8" standalone="yes" ?' . ">\n"; |
||
| 12 | $out .= "<error>\n"; |
||
| 13 | $out .= $this->tag('type', get_class($e)); |
||
| 14 | $out .= $this->tag('message', $this->cdata($e->getMessage())); |
||
| 15 | $out .= $this->tag('code', $this->cdata($e->getCode())); |
||
| 16 | $out .= $this->tag('file', $e->getFile()); |
||
| 17 | $out .= $this->tag('line', $e->getLine()); |
||
| 18 | $out .= $this->tag('trace', $e->getTraceAsString()); |
||
| 19 | $out .= '</error>'; |
||
| 20 | return $out; |
||
| 21 | } |
||
| 22 | |||
| 23 | private function tag(string $name, string $value): string |
||
| 24 | { |
||
| 25 | return "<$name>" . $value . "</$name>\n"; |
||
| 26 | } |
||
| 27 | |||
| 28 | private function cdata(string $value): string |
||
| 31 | } |
||
| 32 | } |
||
| 33 |