BillMeServiceProvider::boot()   B
last analyzed

Complexity

Conditions 7
Paths 3

Size

Total Lines 62

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 7.8957
c 0
b 0
f 0
cc 7
nc 3
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Author: Emmanuel Paul Mnzava
5
 * Twitter: @epmnzava
6
 * Github: https://github.com/dbrax/bill-me
7
 * Email: [email protected]
8
 * 
9
 */
10
11
namespace Epmnzava\BillMe;
12
13
use Illuminate\Support\ServiceProvider;
14
15
class BillMeServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Bootstrap the application services.
19
     */
20
    public function boot()
21
    {
22
        /*
23
         * Optional methods to load your package assets
24
         */
25
        // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'bill-me');
26
        // $this->loadViewsFrom(__DIR__.'/../resources/views', 'bill-me');
27
        // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
28
        // $this->loadRoutesFrom(__DIR__.'/routes.php');
29
30
31
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'billme');
32
33
34
        $this->publishes([
35
            __DIR__.'/../resources/views' => resource_path('views/vendor/billme'),
36
        ]);
37
38
        
39
        if ($this->app->runningInConsole()) {
40
            $this->publishes([
41
                __DIR__ . '/../config/config.php' => config_path('bill-me.php'),
42
            ], 'config');
43
44
45
            //publishing migrations here..
46
            if (!class_exists('CreateOrdersTable') && !class_exists('CreateOrderItemsTable') && !class_exists('CreateInvoicesTable') && !class_exists('CreatePaymentMethodTable') && !class_exists('CreatePaymentsTable')) {
47
                $this->publishes([
48
                    __DIR__ . '/../database/migrations/create_orders_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_orders_table.php'),
49
                    __DIR__ . '/../database/migrations/create_order_items_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_order_items_table.php'),
50
                    __DIR__ . '/../database/migrations/create_invoices_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_invoices_table.php'),
51
                    __DIR__ . '/../database/migrations/create_payment_method_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_payment_method_table.php'),
52
                    __DIR__ . '/../database/migrations/create_billing_payment_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_billing_payment_table.php'),
53
                    __DIR__ . '/../database/migrations/create_receipts_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_receipts_table.php'),
54
                      __DIR__ . '/../database/migrations/create_payment_method_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_payment_method_table.php'),
55
56
                ], 'migrations');
57
            }
58
59
            
60
61
62
63
            // Publishing the views.
64
            /*$this->publishes([
65
                __DIR__.'/../resources/views' => resource_path('views/vendor/bill-me'),
66
            ], 'views');*/
67
68
            // Publishing assets.
69
            /*$this->publishes([
70
                __DIR__.'/../resources/assets' => public_path('vendor/bill-me'),
71
            ], 'assets');*/
72
73
            // Publishing the translation files.
74
            /*$this->publishes([
75
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/bill-me'),
76
            ], 'lang');*/
77
78
            // Registering package commands.
79
            // $this->commands([]);
80
        }
81
    }
82
83
    /**
84
     * Register the application services.
85
     */
86
    public function register()
87
    {
88
        // Automatically apply the package configuration
89
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'bill-me');
90
91
        // Register the main class to use with the facade
92
        $this->app->singleton('bill-me', function () {
93
            return new BillMe;
94
        });
95
    }
96
}
97