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

slimphp / Slim-Skeleton / 3875948887

pending completion
3875948887

push

github

GitHub
Merge pull request #304 from slimphp/dependabot/composer/phpunit/phpunit-tw-9.5.27

94 of 162 relevant lines covered (58.02%)

1.99 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
    private Request $request;
14

15
    private HttpErrorHandler $errorHandler;
16

17
    private bool $displayErrorDetails;
18

19
    public function __construct(
20
        Request $request,
21
        HttpErrorHandler $errorHandler,
22
        bool $displayErrorDetails
23
    ) {
24
        $this->request = $request;
×
25
        $this->errorHandler = $errorHandler;
×
26
        $this->displayErrorDetails = $displayErrorDetails;
×
27
    }
28

29
    public function __invoke()
30
    {
31
        $error = error_get_last();
×
32
        if ($error) {
×
33
            $errorFile = $error['file'];
×
34
            $errorLine = $error['line'];
×
35
            $errorMessage = $error['message'];
×
36
            $errorType = $error['type'];
×
37
            $message = 'An error while processing your request. Please try again later.';
×
38

39
            if ($this->displayErrorDetails) {
×
40
                switch ($errorType) {
41
                    case E_USER_ERROR:
×
42
                        $message = "FATAL ERROR: {$errorMessage}. ";
×
43
                        $message .= " on line {$errorLine} in file {$errorFile}.";
×
44
                        break;
×
45

46
                    case E_USER_WARNING:
×
47
                        $message = "WARNING: {$errorMessage}";
×
48
                        break;
×
49

50
                    case E_USER_NOTICE:
×
51
                        $message = "NOTICE: {$errorMessage}";
×
52
                        break;
×
53

54
                    default:
55
                        $message = "ERROR: {$errorMessage}";
×
56
                        $message .= " on line {$errorLine} in file {$errorFile}.";
×
57
                        break;
×
58
                }
59
            }
60

61
            $exception = new HttpInternalServerErrorException($this->request, $message);
×
62
            $response = $this->errorHandler->__invoke(
×
63
                $this->request,
×
64
                $exception,
×
65
                $this->displayErrorDetails,
×
66
                false,
×
67
                false,
×
68
            );
×
69

70
            $responseEmitter = new ResponseEmitter();
×
71
            $responseEmitter->emit($response);
×
72
        }
73
    }
74
}
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

© 2025 Coveralls, Inc