AppBuildServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 31 2
A register() 0 10 1
A routeConfiguration() 0 7 1
1
<?php
2
3
namespace Faithgen\AppBuild;
4
5
use Faithgen\AppBuild\Models\Module;
6
use Faithgen\AppBuild\Models\Template;
7
use Faithgen\AppBuild\Observers\ModuleObserver;
8
use Faithgen\AppBuild\Observers\TemplateObserver;
9
use Faithgen\AppBuild\Services\BuildService;
10
use Faithgen\AppBuild\Services\ModuleService;
11
use Faithgen\AppBuild\Services\TemplateService;
12
use FaithGen\SDK\Traits\ConfigTrait;
13
use Illuminate\Support\ServiceProvider;
14
15
class AppBuildServiceProvider extends ServiceProvider
16
{
17
    use ConfigTrait;
18
19
    /**
20
     * Bootstrap the application services.
21
     */
22
    public function boot()
23
    {
24
        $this->registerRoutes(__DIR__.'/../routes/build.php', __DIR__.'/../routes/source.php');
25
26
        $this->setUpSourceFiles(function () {
27
            $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
28
29
            $this->publishes([
30
                __DIR__.'/../config/config.php' => config_path('faithgen-build.php'),
31
            ], 'faithgen-build-config');
32
33
            $this->publishes([
34
                __DIR__.'/../database/migrations/' => database_path('migrations'),
35
            ], 'faithgen-build-migrations');
36
37
            $this->loadFactoriesFrom(__DIR__.'/../database/factories');
38
        });
39
40
        if (! config('faithgen-sdk.source')) {
41
            $this->publishes([
42
                __DIR__.'/../storage' => storage_path('app/public'),
43
            ], 'faithgen-build-storage');
44
        }
45
46
        $this->app->singleton(ModuleService::class);
47
        $this->app->singleton(BuildService::class);
48
        $this->app->singleton(TemplateService::class);
49
50
        Module::observe(ModuleObserver::class);
51
        Template::observe(TemplateObserver::class);
52
    }
53
54
    /**
55
     * Register the application services.
56
     */
57
    public function register()
58
    {
59
        // Automatically apply the package configuration
60
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'faithgen-build');
61
62
        // Register the main class to use with the facade
63
        $this->app->singleton('faithgen-build', function () {
64
            return new AppBuild;
65
        });
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function routeConfiguration(): array
72
    {
73
        return [
74
            'prefix'     => config('faithgen-build.prefix'),
75
            'middleware' => config('faithgen-build.middlewares'),
76
        ];
77
    }
78
}
79