Completed
Pull Request — master (#25)
by
unknown
04:29 queued 01:45
created

PageServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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
    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());
0 ignored issues
show
Documentation introduced by
new \Modules\Page\Entities\Page() is of type object<Modules\Page\Entities\Page>, but the function expects a object<Modules\Core\Repositories\Eloquent\Model>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
51
                if (! Config::get('app.cache')) {
52
                    return $repository;
53
                }
54
55
                return new CachePageDecorator($repository);
56
            }
57
        );
58
    }
59
}
60