LaravelDarajaServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Starnerz\LaravelDaraja;
4
5
use Starnerz\LaravelDaraja\Commands\RegisterC2BUrls;
6
7
class LaravelDarajaServiceProvider extends \Illuminate\Support\ServiceProvider
8
{
9
    /**
10
     * Package path to config.
11
     */
12
    const CONFIG_PATH = __DIR__.'/../config/laravel-daraja.php';
13
14
    /**
15
     * Perform post-registration booting of services.
16
     *
17
     * @return void
18
     */
19
    public function boot()
20
    {
21
        $this->publishes([
22
            self::CONFIG_PATH => config_path('laravel-daraja.php'),
23
        ], 'config');
24
25
        if ($this->app->runningInConsole()) {
26
            $this->commands([
27
                RegisterC2BUrls::class,
28
            ]);
29
        }
30
    }
31
32
    /**
33
     * Register any package services.
34
     *
35
     * @return void
36
     */
37
    public function register()
38
    {
39
        $this->mergeConfigFrom(self::CONFIG_PATH, 'laravel-daraja');
40
41
        $this->app->bind('mpesa-api', function () {
42
            return new MpesaApi();
43
        });
44
    }
45
}
46