FormsServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 7 2
A register() 0 15 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Forms\Providers;
6
7
use Rinvex\Forms\Models\Form;
8
use Rinvex\Forms\Models\FormResponse;
9
use Illuminate\Support\ServiceProvider;
10
use Rinvex\Support\Traits\ConsoleTools;
11
use Rinvex\Forms\Console\Commands\MigrateCommand;
12
use Rinvex\Forms\Console\Commands\PublishCommand;
13
use Rinvex\Forms\Console\Commands\RollbackCommand;
14
15
class FormsServiceProvider extends ServiceProvider
16
{
17
    use ConsoleTools;
18
19
    /**
20
     * The commands to be registered.
21
     *
22
     * @var array
23
     */
24
    protected $commands = [
25
        MigrateCommand::class => 'command.rinvex.forms.migrate',
26
        PublishCommand::class => 'command.rinvex.forms.publish',
27
        RollbackCommand::class => 'command.rinvex.forms.rollback',
28
    ];
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function register()
34
    {
35
        // Merge config
36
        $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.forms');
37
38
        // Bind eloquent models to IoC container
39
        $this->app->singleton('rinvex.forms.form', $formModel = $this->app['config']['rinvex.forms.models.form']);
40
        $formModel === Form::class || $this->app->alias('rinvex.forms.form', Form::class);
41
42
        $this->app->singleton('rinvex.forms.form_response', $formModel = $this->app['config']['rinvex.forms.models.form_response']);
43
        $formModel === FormResponse::class || $this->app->alias('rinvex.forms.form_response', FormResponse::class);
44
45
        // Register console commands
46
        $this->registerCommands($this->commands);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function boot()
53
    {
54
        // Publish Resources
55
        $this->publishesConfig('rinvex/laravel-forms');
56
        $this->publishesMigrations('rinvex/laravel-forms');
57
        ! $this->autoloadMigrations('rinvex/laravel-forms') || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
58
    }
59
}
60