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

tempestphp / tempest-framework / 14130122303

28 Mar 2025 01:33PM UTC coverage: 80.66%. First build
14130122303

Pull #1084

github

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

48 of 79 new or added lines in 9 files covered. (60.76%)

10898 of 13511 relevant lines covered (80.66%)

96.22 hits per line

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

94.74
/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
        if ($response->status->isClientError() || $response->status->isServerError()) {
50✔
16
            $response->setBody($this->renderErrorView($response->status));
11✔
17
        }
18

19
        return $response;
50✔
20
    }
21

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

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