• 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/JsonErrorRenderer.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 json_encode;
11

12
use const JSON_PRETTY_PRINT;
13
use const JSON_UNESCAPED_SLASHES;
14

15
class JsonErrorRenderer extends AbstractErrorRenderer
16
{
17
    public function __invoke(Throwable $exception, bool $displayErrorDetails): string
×
18
    {
19
        $error = ['message' => $this->getErrorTitle($exception)];
×
20

21
        if ($displayErrorDetails) {
×
22
            $error['exception'] = [];
×
23
            do {
24
                $error['exception'][] = $this->formatExceptionFragment($exception);
×
25
            } while ($exception = $exception->getPrevious());
×
26
        }
27

28
        return (string) json_encode($error, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
×
29
    }
30

31
    /**
32
     * @return array<string|int>
33
     */
34
    private function formatExceptionFragment(Throwable $exception): array
×
35
    {
36
        $code = $exception->getCode();
×
37
        return [
×
38
            'type' => get_class($exception),
×
39
            'code' => $code,
×
40
            'message' => $exception->getMessage(),
×
41
            'file' => $exception->getFile(),
×
42
            'line' => $exception->getLine(),
×
43
        ];
×
44
    }
45
}
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