PaystackServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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