AdvertServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of ibrand/advert.
5
 *
6
 * (c) iBrand <https://www.ibrand.cc>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace iBrand\Component\Advert;
13
14
use Illuminate\Database\Eloquent\Relations\Relation;
15
use iBrand\Component\Advert\Repositories\AdvertItemRepository;
16
use iBrand\Component\Advert\Repositories\AdvertRepository;
17
use iBrand\Component\Advert\Repositories\Eloquent\AdvertItemRepositoryEloquent;
18
use iBrand\Component\Advert\Repositories\Eloquent\AdvertRepositoryEloquent;
19
use Illuminate\Support\ServiceProvider;
20
21
class AdvertServiceProvider extends ServiceProvider
22
{
23
    /**
24
     *  Boot the service provider.
25
     */
26 4
    public function boot()
27
    {
28 4
        if (!class_exists('CreateAdvertTables')) {
29 1
            $timestamp = date('Y_m_d_His', time());
30 1
            $this->publishes([
31 1
                __DIR__.'/../migrations/create_advert_tables.php.stub' => database_path()."/migrations/{$timestamp}_create_advert_tables.php",
32 1
            ], 'migrations');
33
        }
34
35 4
        $this->publishes([
36 4
            __DIR__.'/../config/advert.php' => config_path('ibrand/advert.php'),
37
        ]);
38
39 4
        Relation::morphMap(
40 4
            config('ibrand.advert.models')
41
        );
42 4
    }
43
44 4
    public function register()
45
    {
46 4
        $this->app->bind(AdvertRepository::class, AdvertRepositoryEloquent::class);
47 4
        $this->app->bind(AdvertItemRepository::class, AdvertItemRepositoryEloquent::class);
48 4
    }
49
}
50