Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( f35a35...781975 )
by Cristian
04:48
created

CrudServiceProvider::resource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD;
4
5
use Route;
6
use Illuminate\Support\ServiceProvider;
7
8
class CrudServiceProvider 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
     * Perform post-registration booting of services.
19
     *
20
     * @return void
21
     */
22
    public function boot()
23
    {
24
        // LOAD THE VIEWS
25
26
        // - first the published/overwritten views (in case they have any changes)
27
        $this->loadViewsFrom(resource_path('views/vendor/backpack/crud'), 'crud');
28
        // - then the stock views that come with the package, in case a published view might be missing
29
        $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'crud');
30
31
        $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack');
32
33
        // PUBLISH FILES
34
35
        // publish lang files
36
        $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang');
37
38
        // publish views
39
        $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud')], 'views');
40
41
        // publish config file
42
        $this->publishes([__DIR__.'/config' => config_path()], 'config');
43
44
        // publish public Backpack CRUD assets
45
        $this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public');
46
47
        // publish custom files for elFinder
48
        $this->publishes([
49
            __DIR__.'/config/elfinder.php'      => config_path('elfinder.php'),
50
            __DIR__.'/resources/views-elfinder' => resource_path('views/vendor/elfinder'),
51
        ], 'elfinder');
52
53
        // AUTO PUBLISH
54
        if (\App::environment('local')) {
55
            if ($this->shouldAutoPublishPublic()) {
56
                \Artisan::call('vendor:publish', [
57
                    '--provider' => 'Backpack\CRUD\CrudServiceProvider',
58
                    '--tag' => 'public',
59
                ]);
60
            }
61
        }
62
63
        // use the vendor configuration file as fallback
64
        $this->mergeConfigFrom(
65
            __DIR__.'/config/backpack/crud.php',
66
            'backpack.crud'
67
        );
68
    }
69
70
    /**
71
     * Register any package services.
72
     *
73
     * @return void
74
     */
75
    public function register()
76
    {
77
        $this->app->bind('CRUD', function ($app) {
78
            return new CRUD($app);
79
        });
80
81
        // register its dependencies
82
        $this->app->register(\Backpack\Base\BaseServiceProvider::class);
83
        $this->app->register(\Collective\Html\HtmlServiceProvider::class);
84
        $this->app->register(\Barryvdh\Elfinder\ElfinderServiceProvider::class);
85
        $this->app->register(\Intervention\Image\ImageServiceProvider::class);
86
87
        // register their aliases
88
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
89
        $loader->alias('CRUD', \Backpack\CRUD\CrudServiceProvider::class);
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
90
        $loader->alias('Form', \Collective\Html\FormFacade::class);
91
        $loader->alias('Html', \Collective\Html\HtmlFacade::class);
92
        $loader->alias('Image', \Intervention\Image\Facades\Image::class);
93
94
        // map the elfinder prefix
95
        if (! \Config::get('elfinder.route.prefix')) {
96
            \Config::set('elfinder.route.prefix', \Config::get('backpack.base.route_prefix').'/elfinder');
97
        }
98
    }
99
100
    public static function resource($name, $controller, array $options = [])
101
    {
102
        return new CrudRouter($name, $controller, $options);
103
    }
104
105
    /**
106
     * Checks to see if we should automatically publish
107
     * vendor files from the public tag.
108
     *
109
     * @return bool
110
     */
111
    private function shouldAutoPublishPublic()
112
    {
113
        $crudPubPath = public_path('vendor/backpack/crud');
114
115
        if (! is_dir($crudPubPath)) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !is_dir($crudPubPath);.
Loading history...
116
            return true;
117
        }
118
119
        return false;
120
    }
121
}
122