LaravelGoldenpayServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
nc 3
nop 0
dl 0
loc 17
c 1
b 0
f 0
cc 3
rs 9.9
1
<?php
2
3
namespace Orkhanahmadov\LaravelGoldenpay;
4
5
use Illuminate\Support\ServiceProvider;
6
use Orkhanahmadov\Goldenpay\Goldenpay as Library;
7
use Orkhanahmadov\Goldenpay\PaymentInterface;
8
use Orkhanahmadov\LaravelGoldenpay\Commands\ResultCommand;
9
10
class LaravelGoldenpayServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15
    public function boot()
16
    {
17
        $this->app->bind(PaymentInterface::class, Library::class);
18
19
        if ($this->app->runningInConsole()) {
20
            $this->publishes([
21
                __DIR__ . '/../config/config.php' => config_path('goldenpay.php'),
22
            ], 'config');
23
24
            if (! class_exists('CreateGoldenpayPaymentsTable')) {
25
                $this->publishes([
26
                    __DIR__ . '/../database/migrations/goldenpay_payments_table.php.stub' => database_path('migrations/' . date('Y_m_d_His') . '_create_goldenpay_payments_table.php'),
27
                ], 'migrations');
28
            }
29
30
            $this->commands([
31
                ResultCommand::class,
32
            ]);
33
        }
34
    }
35
36
    /**
37
     * Register the application services.
38
     */
39
    public function register()
40
    {
41
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'goldenpay');
42
43
        $this->app->singleton('goldenpay', function () {
44
            return $this->app->make(Goldenpay::class);
45
        });
46
    }
47
}
48