ExceptionHandlerServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 33
ccs 10
cts 10
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerExceptionHandlersRepository() 0 3 1
A extendExceptionHandler() 0 4 1
A register() 0 5 1
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