Completed
Push — master ( 3ac83d...87ffc7 )
by Nicolas
03:17
created

PageServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 0
cbo 3
dl 0
loc 51
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A boot() 0 5 1
A provides() 0 4 1
A registerBindings() 0 15 2
1
<?php namespace Modules\Page\Providers;
2
3
use Illuminate\Support\Facades\Config;
4
use Illuminate\Support\ServiceProvider;
5
use Modules\Page\Entities\Page;
6
use Modules\Page\Repositories\Cache\CachePageDecorator;
7
use Modules\Page\Repositories\Eloquent\EloquentPageRepository;
8
9
class PageServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = false;
17
18
    /**
19
     * Register the service provider.
20
     *
21
     * @return void
22
     */
23
    public function register()
24
    {
25
        $this->registerBindings();
26
    }
27
28
    public function boot()
29
    {
30
        $this->mergeConfigFrom(__DIR__ . '/../Config/config.php', 'asgard.page.config');
31
        $this->publishes([__DIR__ . '/../Config/config.php' => config_path('asgard.page.config' . '.php'), ], 'config');
32
    }
33
34
    /**
35
     * Get the services provided by the provider.
36
     *
37
     * @return array
38
     */
39
    public function provides()
40
    {
41
        return array();
42
    }
43
44
    private function registerBindings()
45
    {
46
        $this->app->bind(
47
            'Modules\Page\Repositories\PageRepository',
48
            function () {
49
                $repository = new EloquentPageRepository(new Page());
50
51
                if (! Config::get('app.cache')) {
52
                    return $repository;
53
                }
54
55
                return new CachePageDecorator($repository);
56
            }
57
        );
58
    }
59
}
60