Service::boot()   B
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 17
nc 2
nop 0
1
<?php namespace GeneaLabs\LaravelWhoopsAtom\Providers;
2
3
use GeneaLabs\LaravelWhoopsAtom\Console\Commands\Publish;
4
use Illuminate\Support\ServiceProvider;
5
6
class Service extends ServiceProvider
7
{
8
    public function boot()
9
    {
10
        if (config('app.env') !== 'production') {
11
            $this->publishes([
12
                __DIR__ . '/../../config/genealabs-laravel-whoops-atom.php'
13
                    => config_path('genealabs-laravel-whoops-atom.php')
14
            ], 'config');
15
16
            config([
17
                'app.editor' => function ($file, $line) {
18
                    $homestead = rtrim(config('genealabs-laravel-whoops-atom.homestead-sites-path'), '/');
19
                    $local = rtrim(config('genealabs-laravel-whoops-atom.local-sites-path'), '/');
20
21
                    if (! $local) {
22
                        return '';
23
                    }
24
25
                    $file = str_replace("{$homestead}/", "{$local}/", $file);
26
27
                    return "atom://open?url=file://{$file}&line={$line}";
28
                },
29
            ]);
30
            $this->commands(Publish::class);
31
            $this->mergeConfigFrom(
32
                __DIR__ . '/../../config/genealabs-laravel-whoops-atom.php',
33
                'genealabs-laravel-whoops-atom'
34
            );
35
        }
36
    }
37
}
38