RestfulServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TomHart\Restful;
4
5
use DebugBar\DataCollector\MessagesCollector;
6
use Illuminate\Contracts\Container\BindingResolutionException;
7
use Illuminate\Routing\ResourceRegistrar;
8
use Illuminate\Support\ServiceProvider;
9
use TomHart\Restful\Concerns\Transformer;
10
use TomHart\Restful\Routing\RestfulResourceRegistrar;
11
use TomHart\Restful\Transformers\DefaultTransformer;
12
13
class RestfulServiceProvider extends ServiceProvider
14
{
15
16
    /**
17
     * Boot the service.
18
     */
19
    public function boot(): void
20
    {
21
        $this->publishes(
22
            [
23
                __DIR__ . '/../config/restful.php' => config_path('restful.php'),
24
            ],
25
            'config'
26
        );
27
    }
28
29
    /**
30
     * Bind the resource registrar
31
     * @return void
32
     */
33
    public function register(): void
34
    {
35
        parent::register();
36
37
        $this->app->bind(ResourceRegistrar::class, RestfulResourceRegistrar::class);
38
39
        $this->app->bind(Transformer::class, DefaultTransformer::class);
40
41
        $this->mergeConfigFrom(__DIR__ . '/../config/restful.php', 'restful');
42
43
        try {
44
            $debugBar = app('debugbar');
45
            $debugBar->addCollector(new MessagesCollector('restful_calls'));
46
        } catch (BindingResolutionException $ex) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
47
        }
48
    }
49
}
50