Passed
Push — master ( b8b2bd...fcde1f )
by Alex
02:15
created

LarapayServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigPath() 0 3 1
A register() 0 6 1
A boot() 0 9 1
1
<?php
2
3
namespace Nxmad\Larapay;
4
5
use Nxmad\Larapay\Contracts\Payments;
6
use Illuminate\Support\ServiceProvider;
7
8
class LarapayServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register Service Provider.
12
     *
13
     * @return void
14
     */
15
    public function register()
16
    {
17
        $this->mergeConfigFrom($this->getConfigPath(), 'larapay');
18
19
        $this->app->singleton(Payments::class, function ($app) {
20
            return new GatewayManager($app['config']);
21
        });
22
    }
23
24
    /**
25
     * Boot Service Provider.
26
     *
27
     * @return void
28
     */
29
    public function boot()
30
    {
31
        $this->publishes([
32
            $this->getConfigPath() => config_path('larapay.php'),
33
        ]);
34
35
        $this->loadViewsFrom(__DIR__ . '/../files/views', 'larapay');
36
37
        $this->loadMigrationsFrom(__DIR__ . '/../files/database/migrations');
38
    }
39
40
    /**
41
     * Get default config path.
42
     *
43
     * @return string
44
     */
45
    protected function getConfigPath(): string
46
    {
47
        return __DIR__ . '/../files/config/larapay.php';
48
    }
49
}
50