LaravelScheduleLoggerServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace PendoNL\LaravelScheduleLogger;
4
5
use Illuminate\Support\ServiceProvider;
6
7
/**
8
 * Class ScheduleLoggerServiceProvider.
9
 */
10
class LaravelScheduleLoggerServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Publishes the config file.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        // Publish the migration if it does not exists
20
        if (!class_exists('CreateSchedulelogsTable')) {
21
            $timestamp = date('Y_m_d_His', time());
22
            $this->publishes([
23
                __DIR__.'/../database/migrations/create_schedulelogs_table.php.stub' => database_path('migrations/'.$timestamp.'_create_schedulelogs_table.php'),
24
            ], 'migrations');
25
        }
26
    }
27
28
    /**
29
     * Register the service provider.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $this->app->singleton('laravel-schedulelogger', function () {
36
            return new \PendoNL\LaravelScheduleLogger\LaravelScheduleLogger();
37
        });
38
39
        $this->app->bind('command.schedulelogger:clean', \PendoNL\LaravelScheduleLogger\Commands\CleanCommand::class);
40
41
        $this->commands([
42
            'command.schedulelogger:clean',
43
        ]);
44
    }
45
}
46