Passed
Pull Request — master (#26)
by Philippe
08:53 queued 03:20
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\Commands\ImageToAssetMigrateCommand;
7
8
class AssetLibraryServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Bootstrap any application services.
19
     *
20
     * @return void
21
     */
22 77
    public function boot()
23
    {
24 77
        if ($this->app->runningInConsole()) {
25 77
            $this->publishes([
26 77
                __DIR__.'/../config/assetlibrary.php' => config_path('assetlibrary.php'),
27 77
            ], 'config');
28
29 77
            $this->mergeConfigFrom(__DIR__.'/../config/assetlibrary.php', 'assetlibrary');
30
31 77
            $this->publishMigrations();
32
33 77
            $this->app->bind('command.assetlibrary:migrate-image', ImageToAssetMigrateCommand::class);
34
35 77
            $this->commands([
36 77
                'command.assetlibrary:migrate-image',
37
            ]);
38
        }
39 77
    }
40
41 77
    public function publishMigrations(): void
42
    {
43 77
        if (! class_exists('CreateAssetTable')) {
44 4
            $this->publishes([
45 4
                __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...
46 4
                        time()).'_create_asset_table.php'),
47 4
            ], 'migrations');
48
        }
49
50 77
        if (! class_exists('CreateMediaTable')) {
51 4
            $this->publishes([
52 4
                __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...
53 4
            ], 'migrations');
54
        }
55 77
    }
56
}
57