VouchersServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 21 3
A register() 0 12 1
1
<?php
2
3
namespace BeyondCode\Vouchers;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class VouchersServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     */
12
    public function boot()
13
    {
14
        $this->loadTranslationsFrom(__DIR__.'/../translations', 'vouchers');
15
16
        if ($this->app->runningInConsole()) {
17
            $this->publishes([
18
                __DIR__.'/../config/config.php' => config_path('vouchers.php'),
19
            ], 'config');
20
21
22
            if (! class_exists('CreateVouchersTable')) {
23
                $this->publishes([
24
                    __DIR__.'/../database/migrations/create_vouchers_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_vouchers_table.php'),
25
                ], 'migrations');
26
            }
27
28
            $this->publishes([
29
                __DIR__.'/../translations' => resource_path('lang/vendor/vouchers'),
30
            ], 'translations');
31
        }
32
    }
33
34
    /**
35
     * Register the application services.
36
     */
37
    public function register()
38
    {
39
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'vouchers');
40
41
        $this->app->singleton('vouchers', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
            $generator = new VoucherGenerator(config('vouchers.characters'), config('vouchers.mask'));
43
            $generator->setPrefix(config('vouchers.prefix'));
44
            $generator->setSuffix(config('vouchers.suffix'));
45
            $generator->setSeparator(config('vouchers.separator'));
46
            return new Vouchers($generator);
47
        });
48
    }
49
}
50