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

tempestphp / tempest-framework / 14129587615

28 Mar 2025 01:03PM UTC coverage: 79.776%. First build
14129587615

Pull #1084

github

web-flow
Merge b96abf853 into ed6f85cc6
Pull Request #1084: feat(router): introduce response processors

43 of 64 new or added lines in 8 files covered. (67.19%)

10899 of 13662 relevant lines covered (79.78%)

95.15 hits per line

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

95.0
/src/Tempest/Router/src/ErrorResponses/ErrorResponseProcessor.php
1
<?php
2

3
namespace Tempest\Router\ErrorResponses;
4

5
use Tempest\Http\Status;
6
use Tempest\Router\Response;
7
use Tempest\Router\ResponseProcessor;
8
use Tempest\View\GenericView;
9
use Tempest\View\View;
10

11
final class ErrorResponseProcessor implements ResponseProcessor
12
{
13
    public function process(Response $response): Response
50✔
14
    {
15
        return match ($response->status) {
50✔
16
            Status::INTERNAL_SERVER_ERROR, Status::NOT_FOUND, Status::FORBIDDEN, Status::UNAUTHORIZED => $response->setBody($this->renderErrorView($response->status)),
50✔
17
            default => $response,
50✔
18
        };
50✔
19
    }
20

21
    private function renderErrorView(Status $status): View
11✔
22
    {
23
        return new GenericView(__DIR__ . '/error.view.php', [
11✔
24
            'css' => $this->getCss(),
11✔
25
            'status' => $status->value,
11✔
26
            'title' => $status->description(),
11✔
27
            'message' => match ($status) {
11✔
28
                Status::INTERNAL_SERVER_ERROR => 'An unexpected server error occurred',
11✔
29
                Status::NOT_FOUND => 'This page could not be found',
11✔
30
                Status::FORBIDDEN => 'You do not have permission to access this page',
1✔
NEW
31
                Status::UNAUTHORIZED => 'You must be authenticated in to access this page',
×
32
                default => $status->description(),
11✔
33
            },
11✔
34
        ]);
11✔
35
    }
36

37
    private function getCss(): string
11✔
38
    {
39
        return file_get_contents(__DIR__ . '/style.css');
11✔
40
    }
41
}
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