Completed
Push — master ( 398d0f...310d56 )
by Pascal
11:17 queued 06:22
created

SpecificationsServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Pbmedia\Specifications\Laravel;
4
5
use Illuminate\Support\ServiceProvider;
6
use Pbmedia\Specifications\Matcher;
7
8
class SpecificationsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        $timestamp = date('Y_m_d_His', time());
16
17
        if (!class_exists('CreateSpecificationsAttributesTable')) {
18
            $this->publishes([
19
                __DIR__ . '/../resources/migrations/create_specifications_attributes_table.php.stub' => database_path('migrations/' . $timestamp . '_create_specifications_attributes_table.php'),
20
            ], 'migrations');
21
        }
22
23
        if (!class_exists('CreateSpecificationsScoresTable')) {
24
            $this->publishes([
25
                __DIR__ . '/../resources/migrations/create_specifications_scores_table.php.stub' => database_path('migrations/' . $timestamp . '_create_specifications_scores_table.php'),
26
            ], 'migrations');
27
        }
28
    }
29
30
    /**
31
     * Register the application services.
32
     */
33
    public function register()
34
    {
35
        $this->app->singleton('laravel-specifications-matcher', function ($app) {
36
            return $app->make(Matcher::class);
37
        });
38
    }
39
}
40