• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IlyasDeckers / ody-core / 13532154862

25 Feb 2025 10:24PM UTC coverage: 30.374% (+1.7%) from 28.706%
13532154862

push

github

web-flow
Update php.yml

544 of 1791 relevant lines covered (30.37%)

9.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Error/Renderers/XmlErrorRenderer.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Ody\Core\Error\Renderers;
5

6
use Ody\Core\Error\AbstractErrorRenderer;
7
use Throwable;
8

9
use function get_class;
10
use function sprintf;
11
use function str_replace;
12

13
/**
14
 * Default application XML Error Renderer
15
 */
16
class XmlErrorRenderer extends AbstractErrorRenderer
17
{
18
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
×
19
    {
20
        $xml = '<' . '?xml version="1.0" encoding="UTF-8" standalone="yes"?' . ">\n";
×
21
        $xml .= "<error>\n  <message>" . $this->createCdataSection($this->getErrorTitle($exception)) . "</message>\n";
×
22

23
        if ($displayErrorDetails) {
×
24
            do {
25
                $xml .= "  <exception>\n";
×
26
                $xml .= '    <type>' . get_class($exception) . "</type>\n";
×
27
                $xml .= '    <code>' . $exception->getCode() . "</code>\n";
×
28
                $xml .= '    <message>' . $this->createCdataSection($exception->getMessage()) . "</message>\n";
×
29
                $xml .= '    <file>' . $exception->getFile() . "</file>\n";
×
30
                $xml .= '    <line>' . $exception->getLine() . "</line>\n";
×
31
                $xml .= "  </exception>\n";
×
32
            } while ($exception = $exception->getPrevious());
×
33
        }
34

35
        $xml .= '</error>';
×
36

37
        return $xml;
×
38
    }
39

40
    /**
41
     * Returns a CDATA section with the given content.
42
     */
43
    private function createCdataSection(string $content): string
×
44
    {
45
        return sprintf('<![CDATA[%s]]>', str_replace(']]>', ']]]]><![CDATA[>', $content));
×
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc