Passed
Push — master ( b51903...6b2d83 )
by Philippe
08:32
created

AssetLibraryServiceProvider::getConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary;
4
5
use Illuminate\Support\ServiceProvider;
6
use Thinktomorrow\AssetLibrary\Models\Asset;
7
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
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
     * Register any package services.
20
     *
21
     * @return void
22
     */
23 65
    public function register()
24
    {
25 65
        $this->publishes([
26 65
            __DIR__.'/../config/assetlibrary.php' => config_path('assetlibrary.php'),
27 65
        ], 'config');
28
29 65
        $this->mergeConfigFrom(__DIR__.'/../config/assetlibrary.php', 'assetlibrary');
30
31 65
        $this->app->singleton('asset', function ($app) {
32
            return new Asset($app);
33 65
        });
34
35 65
        $this->publishMigrations();
36
37 65
    }
38
39 65
    public function publishMigrations(): void
40
    {
41 65 View Code Duplication
        if (! class_exists('CreateAssetTable')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42 1
            $this->publishes([
43 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...
44 1
                        time()).'_create_asset_table.php'),
45 1
            ], 'migrations');
46
        }
47
48 65 View Code Duplication
        if (! class_exists('CreateMediaTable')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49 1
            $this->publishes([
50 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...
51 1
            ], 'migrations');
52
        }
53 65
    }
54
55
    private function getConfig()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
56
    {
57
        if (file_exists(config_path('thinktomorrow/assetlibrary.php'))) {
58
            return require config_path('thinktomorrow/assetlibrary.php');
59
        }
60
        return require __DIR__.'/../config/assetlibrary.php';
61
    }
62
}
63