GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BackProjectServiceProvider::loadHelpers()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Afrittella\BackProject;
4
5
use Afrittella\BackProject\Models\Attachment;
6
use Afrittella\BackProject\Models\Observers\RemoveAttachableWheDeletingAttachment;
7
use Afrittella\BackProject\Models\Observers\RemoveFileWhenDeletingAttachment;
8
use Afrittella\BackProject\Models\Observers\SaveFileWhenAddingAttachment;
9
use Afrittella\BackProject\Services\MediaManager;
10
use Afrittella\BackProject\Services\BackProject;
11
use Afrittella\BackProject\Services\SlugGenerator;
12
use Illuminate\Support\ServiceProvider;
13
use Illuminate\Routing\Router;
14
use function Symfony\Component\HttpKernel\Tests\controller_func;
15
16
17
class BackProjectServiceProvider extends ServiceProvider
18
{
19
20
    protected $defer = false;
21
22
    protected $migrations = [
23
        'ModifyUsersTable' => 'modify_users_table',
24
        'CreateMenusTable' => 'create_menus_table',
25
        'CreateAttachmentsTable' => 'create_attachments_table',
26
        'CreateSocialAccountsTable' => 'create_social_accounts_table',
27
        'UsersAddSocial' => 'users_add_social'
28
    ];
29
30
    protected $helpers = [
31
        'icons'
32
    ];
33
34
    public function boot()
35
    {
36
        // LOAD THE VIEWS
37
        // - first the published views (in case they have any changes)
38
        $this->loadViewsFrom(resource_path('views/vendor/back-project/base'), 'back-project');
39
        // - then the stock views that come with the package, in case a published view might be missing
40
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'back-project');
41
        // Load Translations
42
        $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'back-project');
43
44
        // use the vendor configuration file as fallback
45
        $this->mergeConfigFrom(
46
            __DIR__ . '/../config/config.php', 'back-project'
47
        );
48
49
        $this->routes();
50
51
        $this->publishFiles();
52
53
        //$this->handleMigrations();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
        $this->loadMigrationsFrom(realpath(__DIR__.'/../database/migrations'));
55
56
        $this->registerEvents();
57
58
        $this->registerCommands();
59
60
        $this->registerViewComposers();
61
    }
62
63
    public function register()
64
    {
65
        $this->app->singleton('media-manager', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
            return new MediaManager();
67
        });
68
69
        // TODO
70
        /*$this->app->singleton('back-project', function ($app) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
71
            return new BackProject();
72
        });
73
74
        $this->app->singleton('slug-generator', function ($app) {
75
            return new SlugGenerator();
76
        });*/
77
78
        // register dependencies
79
        $this->app->register(\Prologue\Alerts\AlertsServiceProvider::class);
80
        $this->app->register(\Spatie\Permission\PermissionServiceProvider::class);
81
        $this->app->register(\PendoNL\LaravelFontAwesome\LaravelFontAwesomeServiceProvider::class);
82
        $this->app->register(\Collective\Html\HtmlServiceProvider::class);
83
        $this->app->register(\Laravolt\Avatar\ServiceProvider::class);
84
        $this->app->register(\Intervention\Image\ImageServiceProvider::class);
85
        $this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class);
86
87
        // register their aliases
88
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
89
        $loader->alias('Alert', \Prologue\Alerts\Facades\Alert::class);
90
        $loader->alias('FontAwesome', \PendoNL\LaravelFontAwesome\Facade::class);
91
        $loader->alias('Form', \Collective\Html\FormFacade::class);
92
        $loader->alias('Html', \Collective\Html\HtmlFacade::class);
93
        $loader->alias('Avatar', \Laravolt\Avatar\Facade::class);
94
        $loader->alias('MediaManager', \Afrittella\BackProject\Facades\MediaManager::class);
95
        $loader->alias('SlugGenerator', \Afrittella\BackProject\Facades\SlugGenerator::class);
96
        $loader->alias('Image', \Intervention\Image\Facades\Image::class);
97
        $loader->alias('Socialite', \Laravel\Socialite\Facades\Socialite::class);
98
99
        $this->loadHelpers();
100
101
    }
102
103
    /*** Internal function ***/
104
105
    public function publishFiles()
106
    {
107
        // publish config file
108
        $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config');
109
        // publish lang files
110
        $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang');
111
        // publish public BackProject assets
112
        $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public');
113
        // publish views
114
        $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views');
115
        // publish error views
116
        $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors');
117
        // publish public AdminLTE assets
118
        $this->publishes(['vendor/almasaeed2010/adminlte/bower_components/bootstrap/dist' => public_path('vendor/adminlte/bootstrap')], 'adminlte');
119
        $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte');
120
        $this->publishes(['vendor/almasaeed2010/adminlte/plugins' => public_path('vendor/adminlte/plugins')], 'adminlte');
121
    }
122
123
    public function routes()
124
    {
125
        // Register Middleware
126
        $router = app('router');
0 ignored issues
show
Unused Code introduced by
$router is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
127
128
        //$router->aliasMiddleware('admin', \Afrittella\BackProject\Http\Middleware\Admin::class);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
129
        //$router->aliasMiddleware('role', \Afrittella\BackProject\Http\Middleware\Role::class);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
130
131
        $this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
132
    }
133
134
    public function handleMigrations()
135
    {
136
        foreach ($this->migrations as $class => $file) {
137
            if (!class_exists($class)) {
138
                $timestamp = date('Y_m_d_His', time());
139
140
                $this->publishes([
141
                    __DIR__ . '/../database/migrations/' . $file . '.php' =>
142
                        database_path('migrations/' . $timestamp . '_' . $file . '.php')
143
                ], 'migrations');
144
            }
145
        }
146
    }
147
148
    public function registerEvents()
149
    {
150
        // User notification can use queues or not
151
        if (config('back-project.use_queue')) {
152
            \Event::listen('Afrittella\BackProject\Events\UserRegistered', 'Afrittella\BackProject\Listeners\SendRegistrationEmail');
153
        } else {
154
            \Event::listen('Afrittella\BackProject\Events\UserRegistered', 'Afrittella\BackProject\Listeners\SendRegistrationEmailNoQueue');
155
        }
156
157
        // Register Observers
158
        Attachment::observe(SaveFileWhenAddingAttachment::class);
159
        Attachment::observe(RemoveFileWhenDeletingAttachment::class);
160
        Attachment::observe(RemoveAttachableWheDeletingAttachment::class);
161
    }
162
163
    public function registerCommands()
164
    {
165
        if ($this->app->runningInConsole()) {
166
            $this->commands([
167
                \Afrittella\BackProject\Console\Commands\SeedDefaultMenus::class,
168
                \Afrittella\BackProject\Console\Commands\SeedPermissions::class
169
            ]);
170
        }
171
    }
172
173
    public function registerViewComposers()
174
    {
175
        \View::composer(['back-project::layouts.admin'], 'Afrittella\BackProject\Http\ViewComposers\AdminMenuComposer');
176
        \View::composer(['back-project::layouts.admin'], 'Afrittella\BackProject\Http\ViewComposers\UserComposer');
177
    }
178
179
    public function loadHelpers()
180
    {
181
        foreach ($this->helpers as $helper):
182
            $file = __DIR__ . '/Helpers/' . $helper . '.php';
183
184
            if (file_exists($file)) {
185
                require_once($file);
186
            }
187
        endforeach;
188
    }
189
190
}
191