This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 App\Console\Commands; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | |||
7 | class MakeJsonApiDemoRemove extends Command |
||
8 | { |
||
9 | /** |
||
10 | * The name and signature of the console command. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $signature = 'make:demo-remove |
||
15 | {--test : Add files postfix for test}'; |
||
16 | |||
17 | /** |
||
18 | * The console command description. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $description = 'Remove JsonApi Demo entities'; |
||
23 | |||
24 | protected $testPostfix = '-test'; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $controllers = [ |
||
30 | 'LikesController.stub' => 'LikesController.php', |
||
31 | 'SkillsController.stub' => 'SkillsController.php', |
||
32 | 'TeamsController.stub' => 'TeamsController.php', |
||
33 | 'UsersController.stub' => 'UsersController.php' |
||
34 | ]; |
||
35 | |||
36 | protected $models = [ |
||
37 | 'Like.stub' => 'Like.php', |
||
38 | 'Skill.stub' => 'Skill.php', |
||
39 | 'Team.stub' => 'Team.php' |
||
40 | ]; |
||
41 | |||
42 | protected $migrations = [ |
||
43 | 'create_likes_table.stub' => 'create_likes_table.php', |
||
44 | 'create_membership_table.stub' => 'create_membership_table.php', |
||
45 | 'create_skills_table.stub' => 'create_skills_table.php', |
||
46 | 'create_teams_table.stub' => 'create_teams_table.php', |
||
47 | 'add_foreign_keys_to_likes_table.stub' => 'add_foreign_keys_to_likes_table.php', |
||
48 | 'add_foreign_keys_to_membership_table.stub' => 'add_foreign_keys_to_membership_table.php', |
||
49 | 'add_foreign_keys_to_skills_table.stub' => 'add_foreign_keys_to_skills_table.php', |
||
50 | 'add_foreign_keys_to_teams_table.stub' => 'add_foreign_keys_to_teams_table.php' |
||
51 | ]; |
||
52 | |||
53 | protected $seeds = [ |
||
54 | 'TeamsTableSeeder.stub' => 'TeamsTableSeeder.php', |
||
55 | 'TeamUsersTableSeeder.stub' => 'TeamUsersTableSeeder.php', |
||
56 | 'JsonApiSeeder.stub' => 'JsonApiSeeder.php' |
||
57 | ]; |
||
58 | |||
59 | protected $jsonapiEntities = [ |
||
60 | 'JsonApi/Likes/Hydrator.stub' => 'JsonApi/Likes/Hydrator.php', |
||
61 | 'JsonApi/Likes/Request.stub' => 'JsonApi/Likes/Request.php', |
||
62 | 'JsonApi/Likes/Schema.stub' => 'JsonApi/Likes/Schema.php', |
||
63 | 'JsonApi/Likes/Search.stub' => 'JsonApi/Likes/Search.php', |
||
64 | 'JsonApi/Likes/Validators.stub' => 'JsonApi/Likes/Validators.php', |
||
65 | |||
66 | 'JsonApi/Skills/Hydrator.stub' => 'JsonApi/Skills/Hydrator.php', |
||
67 | 'JsonApi/Skills/Request.stub' => 'JsonApi/Skills/Request.php', |
||
68 | 'JsonApi/Skills/Schema.stub' => 'JsonApi/Skills/Schema.php', |
||
69 | 'JsonApi/Skills/Search.stub' => 'JsonApi/Skills/Search.php', |
||
70 | 'JsonApi/Skills/Validators.stub' => 'JsonApi/Skills/Validators.php', |
||
71 | |||
72 | 'JsonApi/Teams/Hydrator.stub' => 'JsonApi/Teams/Hydrator.php', |
||
73 | 'JsonApi/Teams/Request.stub' => 'JsonApi/Teams/Request.php', |
||
74 | 'JsonApi/Teams/Schema.stub' => 'JsonApi/Teams/Schema.php', |
||
75 | 'JsonApi/Teams/Search.stub' => 'JsonApi/Teams/Search.php', |
||
76 | 'JsonApi/Teams/Validators.stub' => 'JsonApi/Teams/Validators.php', |
||
77 | |||
78 | 'JsonApi/Users/Hydrator.stub' => 'JsonApi/Users/Hydrator.php', |
||
79 | 'JsonApi/Users/Request.stub' => 'JsonApi/Users/Request.php', |
||
80 | 'JsonApi/Users/Schema.stub' => 'JsonApi/Users/Schema.php', |
||
81 | 'JsonApi/Users/Search.stub' => 'JsonApi/Users/Search.php', |
||
82 | 'JsonApi/Users/Validators.stub' => 'JsonApi/Users/Validators.php', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * Create a new command instance. |
||
87 | * |
||
88 | */ |
||
89 | public function __construct() |
||
90 | { |
||
91 | parent::__construct(); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Execute the console command. |
||
96 | * |
||
97 | * @return mixed |
||
98 | */ |
||
99 | public function handle() |
||
100 | { |
||
101 | if ($this->option('test')) { |
||
102 | $this->setupTest(); |
||
103 | } |
||
104 | |||
105 | $this->removeJsonApiEntities(); |
||
106 | $this->removeModels(); |
||
107 | $this->removeControllers(); |
||
108 | |||
109 | $this->removeSeeds(); |
||
110 | $this->removeMigrations(); |
||
111 | |||
112 | if (!$this->option('test')) { |
||
113 | $this::call('optimize'); |
||
114 | } |
||
115 | |||
116 | $this->info('JsonApi demo entities removed successfully.'); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * |
||
121 | */ |
||
122 | View Code Duplication | protected function setupTest() |
|
0 ignored issues
–
show
|
|||
123 | { |
||
124 | foreach ($this->migrations as $key => $value) { |
||
125 | $this->migrations[$key] = $value . $this->testPostfix; |
||
126 | } |
||
127 | foreach ($this->seeds as $key => $value) { |
||
128 | $this->seeds[$key] = $value . $this->testPostfix; |
||
129 | } |
||
130 | foreach ($this->controllers as $key => $value) { |
||
131 | $this->controllers[$key] = $value . $this->testPostfix; |
||
132 | } |
||
133 | foreach ($this->models as $key => $value) { |
||
134 | $this->models[$key] = $value . $this->testPostfix; |
||
135 | } |
||
136 | foreach ($this->jsonapiEntities as $key => $value) { |
||
137 | $this->jsonapiEntities[$key] = $value . $this->testPostfix; |
||
138 | } |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * |
||
143 | */ |
||
144 | View Code Duplication | protected function removeModels() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
145 | { |
||
146 | foreach ($this->models as $key => $value) { |
||
147 | if (file_exists(app_path('Models/' . $value))) { |
||
148 | unlink(app_path('Models/' . $value)); |
||
149 | } |
||
150 | } |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * |
||
155 | */ |
||
156 | View Code Duplication | protected function removeControllers() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
157 | { |
||
158 | foreach ($this->controllers as $key => $value) { |
||
159 | if (file_exists(app_path('Http/Controllers/Api/v1/' . $value))) { |
||
160 | unlink(app_path('Http/Controllers/Api/v1/' . $value)); |
||
161 | } |
||
162 | } |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * |
||
167 | */ |
||
168 | protected function removeMigrations() |
||
169 | { |
||
170 | foreach ($this->migrations as $key => $value) { |
||
171 | $mask = database_path('migrations/*' . $value); |
||
172 | array_map( "unlink", glob( $mask ) ); |
||
173 | } |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * |
||
178 | */ |
||
179 | protected function removeSeeds() |
||
180 | { |
||
181 | foreach ($this->seeds as $key => $value) { |
||
182 | if (file_exists(database_path('seeds/' . $value))) { |
||
183 | unlink(database_path('seeds/' . $value)); |
||
184 | } |
||
185 | } |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * |
||
190 | */ |
||
191 | protected function removeJsonApiEntities() |
||
192 | { |
||
193 | try { |
||
194 | foreach ($this->jsonapiEntities as $key => $value) { |
||
195 | if (file_exists(app_path($value))) { |
||
196 | unlink(app_path($value)); |
||
197 | } |
||
198 | } |
||
199 | if (file_exists(app_path('JsonApi/Users'))) { |
||
200 | rmdir(app_path('JsonApi/Users')); |
||
201 | } |
||
202 | |||
203 | if (file_exists(app_path('JsonApi/Likes'))) { |
||
204 | rmdir(app_path('JsonApi/Likes')); |
||
205 | } |
||
206 | |||
207 | if (file_exists(app_path('JsonApi/Skills'))) { |
||
208 | rmdir(app_path('JsonApi/Skills')); |
||
209 | } |
||
210 | |||
211 | if (file_exists(app_path('JsonApi/Teams'))) { |
||
212 | rmdir(app_path('JsonApi/Teams')); |
||
213 | } |
||
214 | |||
215 | if (file_exists(app_path('JsonApi'))) { |
||
216 | if(!@rmdir(app_path('JsonApi'))) { |
||
217 | throw new \League\Flysystem\Exception('JsonApi directory is not empty!'); |
||
218 | }; |
||
219 | } |
||
220 | } catch (\League\Flysystem\Exception $e) { |
||
221 | $this->warn($e->getMessage()); |
||
222 | } |
||
223 | } |
||
224 | } |
||
225 |
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.