FormerServiceProvider::boot()   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
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace AnilcanCakir\Former;
4
5
use Illuminate\Support\ServiceProvider;
6
use AnilcanCakir\Former\Contracts\Former as FormerContract;
7
use AnilcanCakir\Former\Contracts\FormerHelper as FormerHelperContract;
8
9
class FormerServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap any application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->registerResources();
19
    }
20
21
    /**
22
     * Register the Former resources.
23
     *
24
     * @return void
25
     */
26
    protected function registerResources()
27
    {
28
        $this->loadViewsFrom(__DIR__.'/resources/views', 'former');
29
    }
30
31
    /**
32
     * Register the service provider.
33
     *
34
     * @return void
35
     */
36
    public function register()
37
    {
38
        $this->configure();
39
40
        $this->app->singleton(FormerHelperContract::class, function ($app) {
41
            return new FormerHelper($app['view'], $app['translator'], $app['config'], $app['url']);
42
        });
43
44
        $this->app->singleton(FormerContract::class, function ($app) {
45
            return new Former($app[FormerHelperContract::class]);
46
        });
47
    }
48
49
    /**
50
     * Setup the configuration for Former.
51
     *
52
     * @return void
53
     */
54
    protected function configure()
55
    {
56
        $this->mergeConfigFrom(
57
            __DIR__.'/../config/former.php', 'former'
58
        );
59
    }
60
}
61