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

slimphp / Slim-Skeleton / 12974041205

26 Jan 2025 11:05AM UTC coverage: 59.42% (-0.07%) from 59.494%
12974041205

Pull #345

github

web-flow
Merge 7f32837f9 into 0ef015498
Pull Request #345: Upgrading Skeleton to PHP 8.4

7 of 22 new or added lines in 4 files covered. (31.82%)

82 of 138 relevant lines covered (59.42%)

2.06 hits per line

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

0.0
/src/Application/Handlers/ShutdownHandler.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Application\Handlers;
6

7
use App\Application\ResponseEmitter\ResponseEmitter;
8
use Psr\Http\Message\ServerRequestInterface as Request;
9
use Slim\Exception\HttpInternalServerErrorException;
10

11
class ShutdownHandler
12
{
13
    public function __construct(
14
        private Request $request,
15
        private HttpErrorHandler $errorHandler,
16
        private bool $displayErrorDetails
17
    ) {
18
    }
×
19

20
    public function __invoke()
21
    {
22
        $error = error_get_last();
×
23
        if (!$error) {
×
24
            return;
×
25
        }
26

27
        $message = $this->getErrorMessage($error);
×
28
        $exception = new HttpInternalServerErrorException($this->request, $message);
×
29
        $response = $this->errorHandler->__invoke(
×
30
            $this->request,
×
31
            $exception,
×
32
            $this->displayErrorDetails,
×
33
            false,
×
34
            false,
×
35
        );
×
36

37
        $responseEmitter = new ResponseEmitter();
×
38
        $responseEmitter->emit($response);
×
39
    }
40

41
    /**
42
     * @param array{type: int, message: string, file: string, line: int}|null$error
43
     */
44
    private function getErrorMessage(?array $error = null): string
45
    {
46
        if (!$this->displayErrorDetails) {
×
47
            return 'An error while processing your request. Please try again later.';
×
48
        }
49

NEW
50
        $errorFile = $error['file'] ?? null;
×
NEW
51
        $errorLine = $error['line'] ?? null;
×
NEW
52
        $errorMessage = $error['message'] ?? null;
×
NEW
53
        $errorType = $error['type'] ?? null;
×
54

NEW
55
        return match ($errorType) {
×
NEW
56
            E_USER_WARNING => "WARNING: {$errorMessage}",
×
NEW
57
            E_USER_NOTICE => "NOTICE: {$errorMessage}",
×
NEW
58
            default => "FATAL ERROR: {$errorMessage}. on line {$errorLine} in file {$errorFile}."
×
NEW
59
        };
×
60
    }
61
}
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