Passed
Push — master ( 8926af...beb5fc )
by Anton
02:16
created

ErrorHandlerBootloader::defineDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Spiral\Bootloader\Http;
11
12
use Spiral\Boot\Bootloader\Bootloader;
13
use Spiral\Boot\EnvironmentInterface;
14
use Spiral\Core\Container\Autowire;
15
use Spiral\Http\ErrorHandler;
16
use Spiral\Http\Middleware\ErrorHandlerMiddleware;
17
18
/**
19
 * Enable support for HTTP error pages.
20
 */
21
final class ErrorHandlerBootloader extends Bootloader
22
{
23
    const DEPENDENCIES = [
24
        HttpBootloader::class
25
    ];
26
27
    const BINDINGS = [
28
        ErrorHandler\RendererInterface::class => ErrorHandler\PlainRenderer::class,
29
    ];
30
31
    /**
32
     * @param HttpBootloader       $http
33
     * @param EnvironmentInterface $env
34
     */
35
    public function boot(HttpBootloader $http, EnvironmentInterface $env)
36
    {
37
        $http->addMiddleware(new Autowire(
38
            ErrorHandlerMiddleware::class,
39
            ['suppressErrors' => !$env->get('DEBUG', false)]
40
        ));
41
    }
42
}
43