These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Acacha\AdminLTETemplateLaravel\Console; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | |||
7 | /** |
||
8 | * Class MakeVC. |
||
9 | */ |
||
10 | View Code Duplication | class MakeVC extends Command |
|
0 ignored issues
–
show
|
|||
11 | { |
||
12 | |||
13 | /** |
||
14 | * The name and signature of the console command. |
||
15 | */ |
||
16 | protected $signature = 'make:vc {link : The route link} {action? : View or controller to create} |
||
17 | {--t|type=controller : Type of route to create (regular,controller,resource)} {--m|method=get : HTTP method} |
||
18 | {--api : Route is an api route}'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Create a view with his corresponding controller and route |
||
26 | (vc: view controller) and menu entry'; |
||
27 | |||
28 | /** |
||
29 | * MakeVC constructor. |
||
30 | */ |
||
31 | public function __construct() |
||
32 | { |
||
33 | parent::__construct(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Execute the console command. |
||
38 | */ |
||
39 | public function handle() |
||
40 | { |
||
41 | $this->info('Running command ' . $command = $this->command()); |
||
42 | passthru($command); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Obtain command. |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | protected function command() |
||
51 | { |
||
52 | $api = $this->option('api') ? ' --api ' : ''; |
||
53 | $action = $this->argument('action') ? ' ' . $this->argument('action') . ' ' : ''; |
||
54 | return 'php artisan make:route ' . $this->argument('link') . $action . ' --type=' . $this->option('type') . |
||
55 | ' --method=' . $this->option('method') . |
||
56 | $api . |
||
57 | ' -a --menu'; |
||
58 | } |
||
59 | } |
||
60 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.