PageServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    /**
29
     * Get the services provided by the provider.
30
     *
31
     * @return array
32
     */
33
    public function provides()
34
    {
35
        return array();
36
    }
37
38
    private function registerBindings()
39
    {
40
        $this->app->bind(
41
            'Modules\Page\Repositories\PageRepository',
42
            function () {
43
                $repository = new EloquentPageRepository(new Page());
44
45
                if (! Config::get('app.cache')) {
46
                    return $repository;
47
                }
48
49
                return new CachePageDecorator($repository);
50
            }
51
        );
52
    }
53
}
54