ServicesServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 0
1
<?php
2
3
namespace PerfectOblivion\Services;
4
5
use PerfectOblivion\Services\Commands\ServiceMakeCommand;
6
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
7
8
class ServicesServiceProvider extends BaseServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = true;
16
17
    /**
18
     * Register the service provider.
19
     */
20
    public function register()
21
    {
22
        $this->app->singleton(ServiceCaller::class, function ($app) {
23
            return new ServiceCaller($app);
24
        });
25
26
        $this->app->alias(
27
            ServiceCaller::class,
28
            AbstractServiceCaller::class
29
        );
30
    }
31
32
    /**
33
     * Bootstrap the application services.
34
     */
35
    public function boot()
36
    {
37
        if ($this->app->runningInConsole()) {
38
            $this->publishes([
39
                __DIR__.'/../config/service-classes.php' => config_path('service-classes.php'),
40
            ]);
41
        }
42
43
        $this->mergeConfigFrom(__DIR__.'/../config/service-classes.php', 'service-classes');
44
45
        $this->commands([
46
            ServiceMakeCommand::class,
47
        ]);
48
49
        ServiceCaller::setHandlerMethod(config('service-classes.method', 'run'));
50
    }
51
52
    /**
53
     * Get the services provided by the provider.
54
     *
55
     * @return array
56
     */
57
    public function provides()
58
    {
59
        return [
60
            ServiceCaller::class,
61
            AbstractServiceCaller::class,
62
        ];
63
    }
64
}
65