AdjusterServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
3
namespace Mangopixel\Adjuster;
4
5
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
7
/**
8
 * The Laravel Adjuster service provider, which is where the package is bootstrapped.
9
 *
10
 * @package Laravel Adjuster
11
 * @author  Alexander Tømmerås <[email protected]>
12
 * @license The MIT License
13
 */
14
class AdjusterServiceProvider extends BaseServiceProvider
15
{
16
    /**
17
     * Indicates if loading of the provider is deferred.
18
     *
19
     * @var bool
20
     */
21
    protected $defer = false;
22
23
    /**
24
     * Bootstrap the application events.
25
     *
26
     * @return void
27
     */
28
    public function boot()
29
    {
30
        $this->publishes( [
31
            __DIR__ . '/../resources/config/adjuster.php' => config_path( 'adjuster.php' )
32
        ], 'config' );
33
34
        if ( ! class_exists( 'CreateAdjustmentsTable' ) ) {
35
            $timestamp = date( 'Y_m_d_His', time() );
36
            $this->publishes( [
37
                __DIR__ . '/../resources/migrations/create_adjustments_table.php.stub' => database_path( 'migrations' ) . '/' . $timestamp . '_create_adjustments_table.php',
38
            ], 'migrations' );
39
        }
40
    }
41
42
    /**
43
     * Register the service provider.
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
        $this->mergeConfigFrom( __DIR__ . '/../resources/config/adjuster.php', 'adjuster' );
50
51
        $this->app->bind( 'adjuster.model', function ( $app ) {
52
            return new $app->config[ 'adjuster.adjustment_model' ];
53
        } );
54
    }
55
}