EpormasCommand::routeViewCreate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Bantenprov\DashboardEpormas\Console\Commands;
2
3
use Illuminate\Console\Command;
0 ignored issues
show
Bug introduced by
The type Illuminate\Console\Command was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use Illuminate\Support\Facades\Config;
5
use Symfony\Component\Console\Input\InputOption;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputOption was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\Console\Input\InputArgument;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputArgument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use File;
8
9
/**
10
 * The EpormasCommand class.
11
 *
12
 * @package Bantenprov\DashboardEpormas
13
 * @author  Esza Herdi <[email protected]>
14
 */
15
class EpormasCommand extends Command
16
{
17
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'dashboard:epormas';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'Create Controllers, Models, seeds, and Routes command for DashboardEpormas package';
31
32
    /**
33
     * The console command variable.
34
     *
35
     * @var string
36
     */
37
    protected $stubsController = [
38
       'controllers' => [
39
           'DashboardEpormasController.stub',
40
           'EpormasCategoryController.stub',
41
           'EpormasCityController.stub',
42
           'EpormasCounterController.stub'
43
       ]
44
    ];
45
46
    protected $stubsModel = [
47
       'models' => [
48
           'EpormasCategory.stub',
49
           'EpormasCity.stub',
50
           'EpormasCounter.stub'
51
       ]
52
    ];
53
54
    protected $stubsSeeds = [
55
       'seeds' => [
56
           'EpormasCategoryTableSeeder.stub',
57
           'EpormasCityTableSeeder.stub',
58
           'EpormasCounterTableSeeder.stub'
59
       ]
60
    ];
61
62
    /**
63
     * Create a new command instance.
64
     *
65
     * @return void
66
     */
67
    public function __construct()
68
    {
69
        parent::__construct();
70
    }
71
72
    protected function controllerViewCreate()
73
    {
74
        foreach($this->stubsController['controllers'] as $stub)
75
        {
76
            File::put(base_path('app/Http/Controllers/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/Controllers/'.$stub));
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

76
            File::put(/** @scrutinizer ignore-call */ base_path('app/Http/Controllers/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/Controllers/'.$stub));
Loading history...
77
        }
78
    }
79
80
    protected function modelViewCreate()
81
    {
82
        foreach($this->stubsModel['models'] as $stub)
83
        {
84
            File::put(base_path('app/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/Models/'.$stub));
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
            File::put(/** @scrutinizer ignore-call */ base_path('app/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/Models/'.$stub));
Loading history...
85
        }
86
    }
87
88
    protected function routeViewCreate()
89
    {
90
        File::append(base_path('routes/web.php'),File::get(__DIR__.'/../../stubs/routesweb.stub'));
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
        File::append(/** @scrutinizer ignore-call */ base_path('routes/web.php'),File::get(__DIR__.'/../../stubs/routesweb.stub'));
Loading history...
91
        File::append(base_path('routes/api.php'),File::get(__DIR__.'/../../stubs/routesapi.stub'));
92
    }
93
94
    protected function seedsViewCreate()
95
    {
96
        foreach($this->stubsSeeds['seeds'] as $stub)
97
        {
98
            File::put(base_path('database/seeds/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/seeds/'.$stub));
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
            File::put(/** @scrutinizer ignore-call */ base_path('database/seeds/').str_replace('stub','php',$stub),File::get(__DIR__.'/../../stubs/seeds/'.$stub));
Loading history...
99
        }
100
    }
101
102
    /**
103
     * Execute the console command.
104
     *
105
     * @return mixed
106
     */
107
    public function handle()
108
    {
109
        $this->controllerViewCreate();
110
        $this->modelViewCreate();
111
        $this->routeViewCreate();
112
        $this->seedsViewCreate();
113
        $this->info('Create Controllers, Models, seeds, and Routes for DashboardEpormas package success');
114
    }
115
}
116