MockModelsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Sfneal\Testing\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
use Sfneal\Address\Providers\AddressServiceProvider;
7
8
class MockModelsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any MockModel services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        // Publish migration file (if not already published)
18
        if (! class_exists('CreatePeopleTable')) {
19
            $this->publishes([
20
                __DIR__.'/../database/migrations/create_people_table.php.stub' => database_path(
21
                    'migrations/'.date('Y_m_d_His', time()).'_create_people_table.php'
22
                ),
23
            ], 'migration');
24
        }
25
    }
26
27
    /**
28
     * Register any MockModel services.
29
     *
30
     * @return void
31
     */
32
    public function register()
33
    {
34
        // Only register provider if 'sfneal/address' is installed
35
        if (class_exists(AddressServiceProvider::class)) {
36
            $this->app->register(AddressServiceProvider::class);
37
        }
38
    }
39
}
40