ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
namespace Iben\Statable;
4
5
use Iben\Statable\Services\StateHistoryManager;
6
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
7
8
class ServiceProvider extends BaseServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Bootstrap the application services.
19
     */
20
    public function boot()
21
    {
22
        if ($this->app->runningInConsole()) {
23
            $this->publishes([
24
                __DIR__.'/../config/state-machine.php' => config_path('state-machine.php'),
25
                __DIR__.'/../config/laravel-statable.php' => config_path('laravel-statable.php'),
26
            ], 'config');
27
        }
28
29
        if (! class_exists('CreateStateHistoryTable')) {
30
            $this->publishes([
31
                __DIR__.'/../database/migrations/create_state_history_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_state_history_table.php'),
32
            ], 'migrations');
33
        }
34
    }
35
36
    /**
37
     * Register the application services.
38
     */
39
    public function register()
40
    {
41
        $this->app->bind('StateHistoryManager', function () {
42
            return new StateHistoryManager();
43
        });
44
    }
45
}
46