LaravelGoldenpayServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 35
c 2
b 0
f 0
rs 10
wmc 4

2 Methods

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