Completed
Push — stable ( 4e310e...e60011 )
by Nuno
11:07
created

CollisionServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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 NunoMaduro\Collision\Provider;
15
use Illuminate\Support\ServiceProvider;
16
use NunoMaduro\Collision\Adapters\Phpunit\Listener;
17
use NunoMaduro\Collision\Contracts\Provider as ProviderContract;
18
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
19
use NunoMaduro\Collision\Contracts\Adapters\Phpunit\Listener as ListenerContract;
20
21
/**
22
 * This is an Collision Laravel Adapter Service Provider implementation.
23
 *
24
 * Registers the Error Handler on Laravel.
25
 *
26
 * @author Nuno Maduro <[email protected]>
27
 */
28
class CollisionServiceProvider extends ServiceProvider
29
{
30
    /**
31
     * Indicates if loading of the provider is deferred.
32
     *
33
     * @var bool
34
     */
35
    protected $defer = true;
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 3
    public function register()
41
    {
42 3
        if ($this->app->runningInConsole() && ! $this->app->runningUnitTests()) {
43 1
            $this->app->singleton(ListenerContract::class, Listener::class);
44 1
            $this->app->bind(ProviderContract::class, Provider::class);
45
46 1
            $appExceptionHandler = $this->app->make(ExceptionHandlerContract::class);
47
48 1
            $this->app->singleton(
49 1
                ExceptionHandlerContract::class,
50 1
                function ($app) use ($appExceptionHandler) {
51 1
                    return new ExceptionHandler($app, $appExceptionHandler);
52 1
                }
53
            );
54
        }
55 3
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function provides()
61
    {
62
        return [ProviderContract::class];
63
    }
64
}
65