Test Failed
Push — master ( 83b4ef...37cc60 )
by Gianluca
19:45 queued 19:45
created

MongicommerceServiceProvider::boot()   B

Complexity

Conditions 7
Paths 36

Size

Total Lines 52
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 26
c 2
b 1
f 0
dl 0
loc 52
rs 8.5706
cc 7
nc 36
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Mongi\Mongicommerce;
4
5
use Illuminate\Support\Facades\File;
6
use Illuminate\Support\Facades\Schema;
7
use Illuminate\Support\Facades\View;
8
use Illuminate\Support\ServiceProvider;
9
use Mongi\Mongicommerce\Console\InstallPackage;
10
use Mongi\Mongicommerce\Libraries\Template;
11
use Mongi\Mongicommerce\Models\AdminSetting;
12
use Mongi\Mongicommerce\Models\Category;
13
14
class MongicommerceServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Bootstrap the application services.
18
     */
19
    public function boot()
20
    {
21
        /*
22
         * Optional methods to load your package assets
23
         */
24
        // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'mongicommerce');
25
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'mongicommerce');
0 ignored issues
show
Bug introduced by
The method loadViewsFrom() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $this->/** @scrutinizer ignore-call */ 
26
               loadViewsFrom(__DIR__.'/../resources/views', 'mongicommerce');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
0 ignored issues
show
Bug introduced by
The method loadMigrationsFrom() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->/** @scrutinizer ignore-call */ 
27
               loadMigrationsFrom(__DIR__.'/../database/migrations');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $this->loadRoutesFrom(__DIR__.'/routes.php');
0 ignored issues
show
Bug introduced by
The method loadRoutesFrom() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $this->/** @scrutinizer ignore-call */ 
28
               loadRoutesFrom(__DIR__.'/routes.php');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
29
        if(Schema::hasTable('admin_settings')){
30
            //inject global information into views
31
            View::share('mongicommerce', AdminSetting::first());
32
        }
33
34
        if(Schema::hasTable('categories')){
35
            //inject global information into views
36
            View::share('categories', Template::getStructureCategories());
37
        }
38
39
40
        if ($this->app->runningInConsole()) {
0 ignored issues
show
Bug introduced by
The method runningInConsole() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        if ($this->app->/** @scrutinizer ignore-call */ runningInConsole()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
42
            $config_file = config_path('mongicommerce.php');
43
            if(file_exists($config_file)){
44
                File::delete($config_file);
45
            }
46
47
            // Publishing the config file.
48
            $this->publishes([
0 ignored issues
show
Bug introduced by
The method publishes() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            $this->/** @scrutinizer ignore-call */ 
49
                   publishes([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
                __DIR__.'/../config/config.php' => config_path('mongicommerce.php'),
50
            ], 'config');
51
52
            if(file_exists(resource_path('/views/mongicommerce'))){
53
                File::deleteDirectory(resource_path('/views/mongicommerce'));
54
            }
55
            // Publishing the views.
56
            $this->publishes([
57
                __DIR__.'/../resources/views/shop' => resource_path('/views/mongicommerce'),
58
            ], 'views');
59
60
            if(file_exists(public_path('/mongicommerce/template'))){
61
                File::deleteDirectory(public_path('/mongicommerce/template'));
62
            }
63
            // Publishing assets.
64
            $this->publishes([
65
                __DIR__.'/../resources/assets' => public_path('/mongicommerce/template'),
66
            ], 'assets');
67
68
            // Registering package commands.
69
            $this->commands([
0 ignored issues
show
Bug introduced by
The method commands() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
            $this->/** @scrutinizer ignore-call */ 
70
                   commands([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
                InstallPackage::class
71
            ]);
72
73
            // Publishing the translation files.
74
            /*$this->publishes([
75
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/mongicommerce'),
76
            ], 'lang');*/
77
78
        }
79
    }
80
81
    /**
82
     * Register the application services.
83
     */
84
    public function register()
85
    {
86
        // Automatically apply the package configuration
87
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'mongicommerce');
0 ignored issues
show
Bug introduced by
The method mergeConfigFrom() does not exist on Mongi\Mongicommerce\MongicommerceServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

87
        $this->/** @scrutinizer ignore-call */ 
88
               mergeConfigFrom(__DIR__.'/../config/config.php', 'mongicommerce');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
89
        // Register the main class to use with the facade
90
        $this->app->singleton('mongicommerce', function () {
0 ignored issues
show
Bug introduced by
The method singleton() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
        $this->app->/** @scrutinizer ignore-call */ 
91
                    singleton('mongicommerce', function () {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
            return new Mongicommerce;
92
        });
93
    }
94
}
95