Passed
Push — master ( eda701...d10cb7 )
by Philippe
03:09
created

AssetLibraryServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0013

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 13
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.0013
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary;
4
5
use Illuminate\Support\ServiceProvider;
6
use Thinktomorrow\AssetLibrary\Models\Asset;
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
     * Register any package services.
19
     *
20
     * @return void
21
     */
22 67
    public function register()
23
    {
24 67
        $this->publishes([
25 67
            __DIR__.'/../config/assetlibrary.php' => config_path('assetlibrary.php'),
26 67
        ], 'config');
27
28 67
        $this->mergeConfigFrom(__DIR__.'/../config/assetlibrary.php', 'assetlibrary');
29
30 67
        $this->app->singleton('asset', function ($app) {
31
            return new Asset($app);
32 67
        });
33
34 67
        $this->publishMigrations();
35 67
    }
36
37 67
    public function publishMigrations(): void
38
    {
39 67
        if (! class_exists('CreateAssetTable')) {
40 1
            $this->publishes([
41 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...
42 1
                        time()).'_create_asset_table.php'),
43 1
            ], 'migrations');
44
        }
45
46 67
        if (! class_exists('CreateMediaTable')) {
47 1
            $this->publishes([
48 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...
49 1
            ], 'migrations');
50
        }
51 67
    }
52
}
53