Test Failed
Pull Request — master (#24)
by Philippe
02:54
created

AssetLibraryServiceProvider::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2.004

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
ccs 9
cts 10
cp 0.9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.004
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 67
     */
23
    public function boot()
24 67
    {
25 67
        if ($this->app->runningInConsole()) {
26 67
            $this->publishes([
27
                __DIR__.'/../config/assetlibrary.php' => config_path('assetlibrary.php'),
28 67
            ], 'config');
29
    
30 67
            $this->mergeConfigFrom(__DIR__.'/../config/assetlibrary.php', 'assetlibrary');
31
32 67
            $this->publishMigrations();
33
34 67
            $this->app->bind('command.assetlibrary:migrate-image', ImageToAssetMigrateCommand::class);
35 67
36
            $this->commands([
37 67
                'command.assetlibrary:migrate-image',
38
            ]);
39 67
        }
40 1
    }
41 1
42 1
    public function publishMigrations(): void
43 1
    {
44
        if (! class_exists('CreateAssetTable')) {
45
            $this->publishes([
46 67
                __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 1
        }
50
51 67
        if (! class_exists('CreateMediaTable')) {
52
            $this->publishes([
53
                __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
            ], 'migrations');
55
        }
56
    }
57
}
58