extendExceptionHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Cerbero\ExceptionHandler\Providers;
4
5
use Cerbero\ExceptionHandler\HandlerDecorator;
6
use Cerbero\ExceptionHandler\HandlersRepository;
7
use Illuminate\Contracts\Debug\ExceptionHandler;
8
use Illuminate\Support\ServiceProvider;
9
10
/**
11
 * The exception handler service provider.
12
 *
13
 */
14
class ExceptionHandlerServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Register the service provider.
18
     *
19
     * @return void
20
     */
21 27
    public function register()
22
    {
23 27
        $this->registerExceptionHandlersRepository();
24
25 27
        $this->extendExceptionHandler();
26 27
    }
27
28
    /**
29
     * Register the custom exception handlers repository.
30
     *
31
     * @return void
32
     */
33 27
    private function registerExceptionHandlersRepository()
34
    {
35 27
        $this->app->singleton(HandlersRepository::class, HandlersRepository::class);
36 27
    }
37
38
    /**
39
     * Extend the Laravel default exception handler.
40
     *
41
     * @return void
42
     */
43 27
    private function extendExceptionHandler()
44
    {
45 9
        $this->app->extend(ExceptionHandler::class, function (ExceptionHandler $handler, $app) {
46 27
            return new HandlerDecorator($handler, $app[HandlersRepository::class]);
47 27
        });
48 27
    }
49
}
50