TransitionProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Transitions;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Support\ServiceProvider;
7
use Transitions\Console\GenerateTransition;
8
9
class TransitionProvider extends ServiceProvider
10
{
11
12 12
    public function boot() : void
13
    {
14
15 12
        if ($this->app->runningInConsole()) {
16 12
            $this->publishes([
17 12
                __DIR__ . '/../config/config.php' => config_path('transitions.php'),
18
            ]);
19
        }
20 12
    }
21
22 12
    public function register() : void
23
    {
24
25 12
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'transitions');
26
27
        $this->app->bind(TransitionFactory::class, function (Application $app) {
28
29 3
            return new LaravelTransitionFactory($app);
30 12
        });
31
32
        $this->app->bind(TransitionMiddleware::class, function (Application $app) {
33
34 3
            $config = Config::fromArray($app->make('config')->get('transitions'));
35 3
            return new TransitionMiddleware($config, $app->make(TransitionFactory::class));
36 12
        });
37
38 12
        $this->commands([GenerateTransition::class]);
39 12
    }
40
}
41