Passed
Pull Request — master (#24)
by Philippe
03:23
created

AssetLibraryServiceProvider::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary;
4
5
use Illuminate\Support\ServiceProvider;
6
use Thinktomorrow\AssetLibrary\Models\Asset;
7
use Thinktomorrow\AssetLibrary\Commands\ImageToAssetMigrateCommand;
8
9
class AssetLibraryServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = false;
17
18
    /**
19
     * Bootstrap any application services.
20
     *
21
     * @return void
22
     */
23 72
    public function boot()
24
    {
25 72
        if ($this->app->runningInConsole()) {
26 72
            $this->publishes([
27 72
                __DIR__.'/../config/assetlibrary.php' => config_path('assetlibrary.php'),
28 72
            ], 'config');
29
    
30 72
            $this->mergeConfigFrom(__DIR__.'/../config/assetlibrary.php', 'assetlibrary');
31
32 72
            $this->publishMigrations();
33
34 72
            $this->app->bind('command.assetlibrary:migrate-image', ImageToAssetMigrateCommand::class);
35
36 72
            $this->commands([
37 72
                'command.assetlibrary:migrate-image',
38
            ]);
39
        }
40 72
    }
41
42 72
    public function publishMigrations(): void
43
    {
44 72
        if (! class_exists('CreateAssetTable')) {
45 1
            $this->publishes([
46 1
                __DIR__.'/../database/migrations/create_asset_table.php' => database_path('migrations/'.date('Y_m_d_His',
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
47 1
                        time()).'_create_asset_table.php'),
48 1
            ], 'migrations');
49
        }
50
51 72
        if (! class_exists('CreateMediaTable')) {
52 1
            $this->publishes([
53 1
                __DIR__.'/../../../spatie/laravel-medialibrary/database/migrations/create_media_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_media_table.php'),
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 196 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54 1
            ], 'migrations');
55
        }
56 72
    }
57
}
58