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

SpecificationsServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 3
A register() 0 6 1
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