vojtasvoboda /
oc-webartisan-plugin
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Web artisan routes. Examples: |
||
| 5 | * |
||
| 6 | * - /artisan/v1/cache/clear/abcdef |
||
| 7 | * - /artisan/v1/schedule/run/abcdef |
||
| 8 | * - /artisan/v1/plugin/refresh/acme/foo/abcdef |
||
| 9 | * - /artisan/v1/queued/october/update/abcdef |
||
| 10 | * |
||
| 11 | * @namespace artisan/v1 |
||
| 12 | * @version 1 |
||
| 13 | */ |
||
| 14 | Route::group([ 'prefix' => 'artisan/v1' ], function() |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Run queued command. |
||
| 18 | * |
||
| 19 | * @url queued/{group}/{command}/{hash} |
||
| 20 | * |
||
| 21 | * @method GET |
||
| 22 | */ |
||
| 23 | View Code Duplication | Route::get('queued/{group}/{command}/{hash}', function($group, $command, $hash) |
|
| 24 | { |
||
| 25 | /** @var \VojtaSvoboda\WebArtisan\Classes\CommandRunner $runner */ |
||
| 26 | $runner = App::make(\VojtaSvoboda\WebArtisan\Classes\CommandRunner::class); |
||
| 27 | $result = $runner->runQueued($group . ':' . $command, $hash); |
||
| 28 | if ($result !== true) { |
||
| 29 | exit($result); |
||
| 30 | } |
||
| 31 | }); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Run plugin command. |
||
| 35 | * |
||
| 36 | * @url {group}/{command}/{vendor}/{plugin}/{hash} |
||
| 37 | * |
||
| 38 | * @method GET |
||
| 39 | */ |
||
| 40 | View Code Duplication | Route::get('{group}/{command}/{vendor}/{plugin}/{hash}', function($group, $command, $vendor, $plugin, $hash) |
|
|
0 ignored issues
–
show
|
|||
| 41 | { |
||
| 42 | /** @var \VojtaSvoboda\WebArtisan\Classes\CommandRunner $runner */ |
||
| 43 | $runner = App::make(\VojtaSvoboda\WebArtisan\Classes\CommandRunner::class); |
||
| 44 | $result = $runner->runForPlugin($group . ':' . $command, $vendor . '.' . $plugin, $hash); |
||
| 45 | if ($result !== true) { |
||
| 46 | exit($result); |
||
| 47 | } |
||
| 48 | }); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Run command. |
||
| 52 | * |
||
| 53 | * @url {group}/{command}/{hash} |
||
| 54 | * |
||
| 55 | * @method GET |
||
| 56 | */ |
||
| 57 | View Code Duplication | Route::get('{group}/{command}/{hash}', function($group, $command, $hash) |
|
| 58 | { |
||
| 59 | /** @var \VojtaSvoboda\WebArtisan\Classes\CommandRunner $runner */ |
||
| 60 | $runner = App::make(\VojtaSvoboda\WebArtisan\Classes\CommandRunner::class); |
||
| 61 | $result = $runner->run($group . ':' . $command, $hash); |
||
| 62 | if ($result !== true) { |
||
| 63 | exit($result); |
||
| 64 | } |
||
| 65 | }); |
||
| 66 | }); |
||
| 67 |
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.