PayPalServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeConfig() 0 5 1
A boot() 0 9 1
A register() 0 5 1
A registerPayPal() 0 4 1
1
<?php
2
3
namespace Srmklive\PayPal\Providers;
4
5
/*
6
 * Class PayPalServiceProvider
7
 * @package Srmklive\PayPal
8
 */
9
10
use Illuminate\Support\ServiceProvider;
11
use Srmklive\PayPal\Services\PayPal as PayPalClient;
12
13
class PayPalServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Indicates if loading of the provider is deferred.
17
     *
18
     * @var bool
19
     */
20
    protected $defer = false;
21
22
    /**
23
     * Bootstrap the application events.
24
     *
25
     * @return void
26
     */
27
    public function boot()
28
    {
29
        // Publish config files
30
        $this->publishes([
31
            __DIR__.'/../../config/config.php' => config_path('paypal.php'),
32
        ]);
33
34
        // Publish Lang Files
35
        $this->loadTranslationsFrom(__DIR__.'/../../lang', 'paypal');
36
    }
37
38
    /**
39
     * Register the service provider.
40
     *
41
     * @return void
42
     */
43
    public function register()
44
    {
45
        $this->registerPayPal();
46
47
        $this->mergeConfig();
48
    }
49
50
    /**
51
     * Register the application bindings.
52
     *
53
     * @return void
54
     */
55
    private function registerPayPal()
56
    {
57
        $this->app->singleton('paypal_client', static function () {
58
            return new PayPalClient();
59
        });
60
    }
61
62
    /**
63
     * Merges user's and paypal's configs.
64
     *
65
     * @return void
66
     */
67
    private function mergeConfig()
68
    {
69
        $this->mergeConfigFrom(
70
            __DIR__.'/../../config/config.php',
71
            'paypal'
72
        );
73
    }
74
}
75