• 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/HtmlErrorRenderer.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 htmlentities;
11
use function sprintf;
12

13
class HtmlErrorRenderer extends AbstractErrorRenderer
14
{
15
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
×
16
    {
17
        if ($displayErrorDetails) {
×
18
            $html = '<p>The application could not run because of the following error:</p>';
×
19
            $html .= '<h2>Details</h2>';
×
20
            $html .= $this->renderExceptionFragment($exception);
×
21
        } else {
22
            $html = "<p>{$this->getErrorDescription($exception)}</p>";
×
23
        }
24

25
        return $this->renderHtmlBody($this->getErrorTitle($exception), $html);
×
26
    }
27

28
    private function renderExceptionFragment(Throwable $exception): string
×
29
    {
30
        $html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));
×
31

32
        $code = $exception->getCode();
×
33
        $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
×
34

35
        $html .= sprintf('<div><strong>Message:</strong> %s</div>', htmlentities($exception->getMessage()));
×
36

37
        $html .= sprintf('<div><strong>File:</strong> %s</div>', $exception->getFile());
×
38

39
        $html .= sprintf('<div><strong>Line:</strong> %s</div>', $exception->getLine());
×
40

41
        $html .= '<h2>Trace</h2>';
×
42
        $html .= sprintf('<pre>%s</pre>', htmlentities($exception->getTraceAsString()));
×
43

44
        return $html;
×
45
    }
46

47
    public function renderHtmlBody(string $title = '', string $html = ''): string
×
48
    {
49
        return sprintf(
×
50
            '<!doctype html>' .
×
51
            '<html lang="en">' .
×
52
            '    <head>' .
×
53
            '        <meta charset="utf-8">' .
×
54
            '        <meta name="viewport" content="width=device-width, initial-scale=1">' .
×
55
            '        <title>%s</title>' .
×
56
            '        <style>' .
×
57
            '            body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif}' .
×
58
            '            h1{margin:0;font-size:48px;font-weight:normal;line-height:48px}' .
×
59
            '            strong{display:inline-block;width:65px}' .
×
60
            '        </style>' .
×
61
            '    </head>' .
×
62
            '    <body>' .
×
63
            '        <h1>%s</h1>' .
×
64
            '        <div>%s</div>' .
×
65
            '        <a href="#" onclick="window.history.go(-1)">Go Back</a>' .
×
66
            '    </body>' .
×
67
            '</html>',
×
68
            $title,
×
69
            $title,
×
70
            $html
×
71
        );
×
72
    }
73
}
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