Completed
Push — develop ( b95546...cfaf44 )
by Abdelrahman
01:13
created

AttributesServiceProvider::publishResources()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Attributes\Providers;
6
7
use Illuminate\Support\ServiceProvider;
8
use Rinvex\Support\Traits\ConsoleTools;
9
use Rinvex\Attributes\Models\Attribute;
10
use Rinvex\Attributes\Models\AttributeEntity;
11
use Rinvex\Attributes\Console\Commands\MigrateCommand;
12
use Rinvex\Attributes\Console\Commands\PublishCommand;
13
use Rinvex\Attributes\Console\Commands\RollbackCommand;
14
15
class AttributesServiceProvider 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.attributes.migrate',
26
        PublishCommand::class => 'command.rinvex.attributes.publish',
27
        RollbackCommand::class => 'command.rinvex.attributes.rollback',
28
    ];
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function register()
34
    {
35
        // Merge config
36
        $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.attributes');
37
38
        // Bind eloquent models to IoC container
39
        $this->app->singleton('rinvex.attributes.attribute', $attributeyModel = $this->app['config']['rinvex.attributes.models.attribute']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 140 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
40
        $attributeyModel === Attribute::class || $this->app->alias('rinvex.attributes.attribute', Attribute::class);
41
42
        $this->app->singleton('rinvex.attributes.attribute_entity', $attributeEntityModel = $this->app['config']['rinvex.attributes.models.attribute_entity']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 159 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
43
        $attributeEntityModel === AttributeEntity::class || $this->app->alias('rinvex.attributes.attribute_entity', AttributeEntity::class);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 140 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
44
45
        // Register attributes entities
46
        $this->app->singleton('rinvex.attributes.entities', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
            return collect();
48
        });
49
50
        // Register console commands
51
        ! $this->app->runningInConsole() || $this->registersCommands();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function boot()
58
    {
59
        // Publish Resources
60
        ! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-attributes');
61
        ! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-attributes');
62
    }
63
}
64