YandexCheckoutServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 3
eloc 9
c 3
b 1
f 0
nc 3
nop 0
dl 0
loc 14
rs 9.9666
1
<?php
2
3
namespace Orkhanahmadov\YandexCheckout;
4
5
use Illuminate\Support\ServiceProvider;
6
use Orkhanahmadov\YandexCheckout\Commands\CheckPaymentCommand;
7
8
class YandexCheckoutServiceProvider extends ServiceProvider
9
{
10
    public function boot()
11
    {
12
        if ($this->app->runningInConsole()) {
13
            $this->publishes([
14
                __DIR__ . '/../config/config.php' => config_path('yandex-checkout.php'),
15
            ], 'config');
16
17
            if (! class_exists('CreateYandexCheckoutsTable')) {
18
                $this->publishes([
19
                    __DIR__ . '/../database/migrations/yandex_checkouts_table.php.stub' => database_path('migrations/' . date('Y_m_d_His') . '_create_yandex_checkouts_table.php'),
20
                ], 'migrations');
21
            }
22
23
            $this->commands([CheckPaymentCommand::class]);
24
        }
25
    }
26
27
    public function register()
28
    {
29
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'yandex-checkout');
30
31
        $this->app->singleton('yandex-checkout', function () {
32
            return $this->app->make(YandexCheckoutService::class);
33
        });
34
    }
35
}
36