Conditions | 12 |
Paths | 256 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
21 | public function release(Request $request) |
||
22 | { |
||
23 | $releaseObName = $request->has('relo') && ! empty($request->input('relo')) ? $request->input('relo') : ''; |
||
24 | $releasePrName = $request->has('relp') && ! empty($request->input('relp')) ? $request->input('relp') : ''; |
||
25 | $apiToken = $request->has('api_token') && ! empty($request->input('api_token')) ? $request->input('api_token') : ''; |
||
26 | $user = User::query()->where('api_token', $request->input('api_token'))->first(); |
||
27 | if (! $user) { |
||
28 | return response()->json(['message' => 'Indexer inform error, wrong api key!'], 404); |
||
29 | } |
||
30 | |||
31 | if (! empty($releaseObName) && ! empty($releasePrName) && ! empty($apiToken)) { |
||
32 | ReleaseInform::insertOrIgnore(['relOName' => $releaseObName, 'relPName' => $releasePrName, 'api_token' => $apiToken, 'created_at' => now(), 'updated_at' => now()]); |
||
33 | $release = Release::whereSearchname($releaseObName)->first(); |
||
34 | if (! empty($release)) { |
||
35 | (new NameFixer())->updateRelease($release, $releasePrName, 'Release Inform API', true, 'Filenames, ', 1, true); |
||
36 | } |
||
37 | |||
38 | return response()->json(['message' => 'Release Information Added!'], 200); |
||
39 | } |
||
40 | |||
41 | return response()->json(['message' => 'Indexer inform error, wrong data supplied!'], 404); |
||
42 | } |
||
44 |