Passed
Push — master ( ec5386...e56f88 )
by Andrey
53s queued 14s
created

ExceptionHandlerBootloader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 10 1
A __construct() 0 3 1
A boot() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Bootloader;
6
7
use App\Application\Exception\Renderer\ViewRenderer;
8
use Spiral\Boot\AbstractKernel;
0 ignored issues
show
Bug introduced by
The type Spiral\Boot\AbstractKernel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Spiral\Boot\Bootloader\Bootloader;
0 ignored issues
show
Bug introduced by
The type Spiral\Boot\Bootloader\Bootloader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Spiral\Exceptions\ExceptionHandler;
0 ignored issues
show
Bug introduced by
The type Spiral\Exceptions\ExceptionHandler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spiral\Exceptions\Renderer\ConsoleRenderer;
0 ignored issues
show
Bug introduced by
The type Spiral\Exceptions\Renderer\ConsoleRenderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spiral\Exceptions\Renderer\JsonRenderer;
0 ignored issues
show
Bug introduced by
The type Spiral\Exceptions\Renderer\JsonRenderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Spiral\Exceptions\Reporter\FileReporter;
0 ignored issues
show
Bug introduced by
The type Spiral\Exceptions\Reporter\FileReporter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Spiral\Exceptions\Reporter\LoggerReporter;
0 ignored issues
show
Bug introduced by
The type Spiral\Exceptions\Reporter\LoggerReporter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Spiral\Http\ErrorHandler\RendererInterface;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\ErrorHandler\RendererInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Spiral\Http\Middleware\ErrorHandlerMiddleware\EnvSuppressErrors;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\Middleware\E...eware\EnvSuppressErrors was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Spiral\Http\Middleware\ErrorHandlerMiddleware\SuppressErrorsInterface;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\Middleware\E...SuppressErrorsInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 * The exception handler bootloader is responsible for registering the exception renderers and reporters.
21
 *
22
 * @link https://spiral.dev/docs/basics-errors
23
 */
24
final class ExceptionHandlerBootloader extends Bootloader
25
{
26
    protected const BINDINGS = [
27
        SuppressErrorsInterface::class => EnvSuppressErrors::class,
28
        RendererInterface::class => ViewRenderer::class,
29
    ];
30
31
    public function __construct(
32
        private readonly ExceptionHandler $handler,
33
    ) {
34
    }
35
36
    public function init(AbstractKernel $kernel): void
37
    {
38
        // Register the console renderer, that will be used when the application
39
        // is running in the console.
40
        $this->handler->addRenderer(new ConsoleRenderer());
41
42
        $kernel->running(function (): void {
43
            // Register the JSON renderer, that will be used when the application is
44
            // running in the HTTP context and a JSON response is expected.
45
            $this->handler->addRenderer(new JsonRenderer());
46
        });
47
    }
48
49
    public function boot(LoggerReporter $logger, FileReporter $files): void
50
    {
51
        // Register the logger reporter, that will be used to log the exceptions using
52
        // the logger component.
53
        $this->handler->addReporter($logger);
54
55
        // Register the file reporter. It allows you to save detailed information about an exception to a file
56
        // known as snapshot.
57
        $this->handler->addReporter($files);
58
    }
59
}
60