LaravelSchemaCrawlerServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
namespace DanielWerner\LaravelSchemaCrawler;
4
5
use Illuminate\Support\ServiceProvider;
6
use DanielWerner\LaravelSchemaCrawler\Console\Commands\SchemaCrawlerCommand;
7
8
class LaravelSchemaCrawlerServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     *
13
     * @return void
14
     */
15
    public function boot(): void
16
    {
17
        /*
18
         * Optional methods to load your package assets
19
         */
20
        if (config('laravel-schemacrawler.routes_enabled')) {
21
            $this->loadRoutesFrom(__DIR__.'/Http/routes.php');
22
        }
23
24
        if ($this->app->runningInConsole()) {
25
            $this->publishes([
26
                __DIR__.'/../config/config.php' => config_path('laravel-schemacrawler.php'),
27
            ], 'config');
28
29
            // Registering package commands.
30
            $this->commands([SchemaCrawlerCommand::class]);
31
        }
32
    }
33
34
    /**
35
     * Register the application services.
36
     *
37
     * @return void
38
     */
39
    public function register(): void
40
    {
41
        // Automatically apply the package configuration
42
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-schemacrawler');
43
44
        // Register the main class to use with the facade
45
        $this->app->singleton('laravel-schemacrawler', function () {
46
            return new LaravelSchemaCrawler;
47
        });
48
    }
49
}
50