PaystackServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 1
cbo 3
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 16 3
A provides() 0 4 1
1
<?php
2
3
namespace Ammezie\Paystack;
4
5
use Illuminate\Support\ServiceProvider;
6
use MAbiola\Paystack\Paystack as MAbiolaPaystack;
7
8
class PaystackServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishes([
18
            __DIR__.'/config/paystack.php' => config_path('paystack-laravel.php'),
19
        ]);
20
    }
21
22
    /**
23
     * Register any application services.
24
     *
25
     * @return void
26
     */
27
    public function register()
28
    {
29
        $this->app->singleton('paystack-laravel', function ($app) {
30
            $config = $app['config']->get('paystack-laravel');
31
32
            if (!$config) {
33
                throw new \RuntimeException('Missing Paystack configuration.');
34
            }
35
36
            if ($config['paystack_mode'] == 'test') {
37
                return MAbiolaPaystack::make($config['test_secret_key']);
38
            }
39
40
            return MAbiolaPaystack::make($config['live_secret_key']);
41
        });
42
    }
43
44
    /**
45
     * Get the services provided by the provider.
46
     *
47
     * @return array
48
     */
49
    public function provides()
50
    {
51
        return ['paystack-laravel'];
52
    }
53
}
54