Completed
Push — stable ( 40e75b...0ef583 )
by Nuno
21:47 queued 05:32
created

CollisionServiceProvider::register()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
cc 3
eloc 8
nc 2
nop 0
crap 3
1
<?php
2
3
/**
4
 * This file is part of Collision.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace NunoMaduro\Collision\Adapters\Laravel;
13
14
use Illuminate\Support\ServiceProvider;
15
use NunoMaduro\Collision\Adapters\Phpunit\Listener;
16
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
17
use NunoMaduro\Collision\Contracts\Adapters\Phpunit\Listener as ListenerContract;
18
19
/**
20
 * This is an Collision Laravel Adapter Service Provider implementation.
21
 *
22
 * Registers the Error Handler on Laravel.
23
 *
24
 * @author Nuno Maduro <[email protected]>
25
 */
26
class CollisionServiceProvider extends ServiceProvider
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31 3
    public function register()
32
    {
33 3
        if ($this->app->runningInConsole() && ! $this->app->runningUnitTests()) {
34 1
            $this->app->singleton(ListenerContract::class, Listener::class);
35
36 1
            $appExceptionHandler = $this->app->make(ExceptionHandlerContract::class);
37
38 1
            $this->app->singleton(
39 1
                ExceptionHandlerContract::class,
40 1
                function ($app) use ($appExceptionHandler) {
41 1
                    return new ExceptionHandler($app, $appExceptionHandler);
42 1
                }
43
            );
44
        }
45 3
    }
46
}
47