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
Pull Request — master (#49)
by
unknown
09:14
created

BackupManagerServiceProvider::boot()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 24
rs 8.9713
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Backpack\BackupManager;
4
5
use Illuminate\Routing\Router;
6
use Illuminate\Support\ServiceProvider;
7
8
class BackupManagerServiceProvider 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
     * Where the route file lives, both inside the package and in the app (if overwritten).
19
     *
20
     * @var string
21
     */
22
    public $routeFilePath = '/routes/backpack/backupmanager.php';
23
24
    /**
25
     * Perform post-registration booting of services.
26
     *
27
     * @return void
28
     */
29
    public function boot()
30
    {
31
        // use the vendor configuration file as fallback
32
        $this->mergeConfigFrom(
33
            __DIR__.'/config/backup.php', 'backpack.backupmanager'
34
        );
35
36
        // LOAD THE VIEWS
37
        // - first the published/overwritten views (in case they have any changes)
38
        $this->loadViewsFrom(resource_path('views/vendor/backpack/backupmanager'), 'backupmanager');
39
        // - then the stock views that come with the package, in case a published view might be missing
40
        $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'backupmanager');
41
        
42
        // load translation
43
        $this->loadTranslationsFrom(resource_path('lang/vendor/backpack'), 'backpack');
44
        $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack');
45
46
        // publish config file
47
        $this->publishes([__DIR__.'/config/backup.php' => config_path('backup.php')], 'config');
48
        // publish lang files
49
        $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang');
50
        // publish the views
51
        $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/backupmanager')], 'views');
52
    }
53
54
    /**
55
     * Define the routes for the application.
56
     *
57
     * @param \Illuminate\Routing\Router $router
58
     *
59
     * @return void
60
     */
61
    public function setupRoutes(Router $router)
0 ignored issues
show
Unused Code introduced by
The parameter $router 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...
62
    {
63
        // by default, use the routes file provided in vendor
64
        $routeFilePathInUse = __DIR__.$this->routeFilePath;
65
66
        // but if there's a file with the same name in routes/backpack, use that one
67
        if (file_exists(base_path().$this->routeFilePath)) {
68
            $routeFilePathInUse = base_path().$this->routeFilePath;
69
        }
70
71
        $this->loadRoutesFrom($routeFilePathInUse);
72
    }
73
74
    /**
75
     * Register any package services.
76
     *
77
     * @return void
78
     */
79
    public function register()
80
    {
81
        $this->setupRoutes($this->app->router);
0 ignored issues
show
Bug introduced by
Accessing router on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
82
83
        // use this if your package has a config file
84
        config([
85
                'config/backup.php',
86
        ]);
87
    }
88
}
89