ArticlesServiceProvider::loadCommands()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Ergare17\Articles\Providers;
4
5
use Ergare17\Articles\Console\Commands\CreateArticleCommand;
6
use Ergare17\Articles\Console\Commands\DeleteArticleCommand;
7
use Ergare17\Articles\Console\Commands\EditArticleCommand;
8
use Ergare17\Articles\Console\Commands\ListArticlesCommand;
9
use Ergare17\Articles\Console\Commands\ShowArticleCommand;
10
use Illuminate\Support\ServiceProvider;
11
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
12
13
class ArticlesServiceProvider extends ServiceProvider
14
{
15
    public function register()
16
    {
17
        if (!defined('ARTICLES_PATH')) {
18
            define('ARTICLES_PATH', realpath(__DIR__.'/../../'));
19
        }
20
        $this->registerEloquentFactoriesFrom(ARTICLES_PATH . '/database/factories');
21
    }
22
23
    public function boot()
24
    {
25
//        dump('Booting Articles package');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
        $this->defineRoutes();
27
        $this->loadViews();
28
        $this->loadMigrations();
29
        $this->loadCommands();
30
    }
31
32
    protected function loadCommands()
33
    {
34
        if ($this->app->runningInConsole()) {
35
            $this->commands([
36
                CreateArticleCommand::class,
37
                ListArticlesCommand::class,
38
                DeleteArticleCommand::class,
39
                ShowArticleCommand::class,
40
                EditArticleCommand::class,
41
            ]);
42
        }
43
    }
44
45
    public function defineRoutes()
46
    {
47
        $this->defineWebRoutes();
48
        $this->defineApiRoutes();
49
    }
50
51
    public function defineWebRoutes()
52
    {
53
        require ARTICLES_PATH.'/routes/web.php';
54
    }
55
56
    public function defineApiRoutes()
57
    {
58
        require ARTICLES_PATH.'/routes/api.php';
59
    }
60
61
    private function loadViews()
62
    {
63
        $this->loadViewsFrom(ARTICLES_PATH.'/resources/views', 'articles');
64
    }
65
66
    private function loadMigrations()
67
    {
68
        $this->loadMigrationsFrom(ARTICLES_PATH.'/database/migrations');
69
    }
70
71
    /**
72
     * Register factories.
73
     *
74
     * @param  string  $path
75
     * @return void
76
     */
77
    protected function registerEloquentFactoriesFrom($path)
78
    {
79
        $this->app->make(EloquentFactory::class)->load($path);
80
    }
81
}
82