ServicesServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 61
rs 10
c 0
b 0
f 0

3 Methods

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