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.

ServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Neurony\Redirects;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Routing\Router;
7
use Illuminate\Support\Facades\File;
8
use Illuminate\Support\Facades\Route;
9
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
10
use Neurony\Redirects\Contracts\RedirectModelContract;
11
use Neurony\Redirects\Middleware\RedirectRequests;
12
use Neurony\Redirects\Models\Redirect;
13
14
class ServiceProvider extends BaseServiceProvider
15
{
16
    /**
17
     * @var Router
18
     */
19
    protected $router;
20
21
    /**
22
     * Create a new service provider instance.
23
     *
24
     * @param Application $app
25
     */
26
    public function __construct(Application $app)
27
    {
28
        parent::__construct($app);
29
    }
30
31
    /**
32
     * Bootstrap the application services.
33
     *
34
     * @param Router $router
35
     * @return void
36
     */
37
    public function boot(Router $router)
38
    {
39
        $this->router = $router;
40
41
        $this->publishConfigs();
42
        $this->publishMigrations();
43
        $this->registerMiddleware();
44
        $this->registerRouteBindings();
45
    }
46
47
    /**
48
     * Register the application services.
49
     *
50
     * @return void
51
     */
52
    public function register()
53
    {
54
        $this->registerBindings();
55
    }
56
57
    /**
58
     * @return void
59
     */
60
    protected function publishConfigs()
61
    {
62
        $this->publishes([
63
            __DIR__.'/../config/redirects.php' => config_path('redirects.php'),
64
        ], 'config');
65
    }
66
67
    /**
68
     * @return void
69
     */
70
    protected function publishMigrations()
71
    {
72
        if (empty(File::glob(database_path('migrations/*_create_redirects_table.php')))) {
73
            $timestamp = date('Y_m_d_His', time());
74
            $migration = database_path("migrations/{$timestamp}_create_redirects_table.php");
75
76
            $this->publishes([
77
                __DIR__.'/../database/migrations/create_redirects_table.php.stub' => $migration,
78
            ], 'migrations');
79
        }
80
    }
81
82
    /**
83
     * @return void
84
     */
85
    protected function registerMiddleware()
86
    {
87
        $this->router->aliasMiddleware('redirect.requests', RedirectRequests::class);
88
    }
89
90
    /**
91
     * @return void
92
     */
93
    protected function registerRouteBindings()
94
    {
95
        Route::model('redirect', RedirectModelContract::class);
96
    }
97
98
    /**
99
     * @return void
100
     */
101
    protected function registerBindings()
102
    {
103
        $this->app->bind(RedirectModelContract::class, $this->config['redirects']['redirect_model'] ?? Redirect::class);
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
104
        $this->app->alias(RedirectModelContract::class, 'redirect.model');
105
    }
106
}
107