| Conditions | 1 |
| Paths | 1 |
| Total Lines | 81 |
| Code Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 26 | public function map(Registrar $router) |
||
| 27 | { |
||
| 28 | |||
| 29 | // Project Area |
||
| 30 | $router->group([ |
||
| 31 | 'middleware' => ['app.hasSetting'], |
||
| 32 | 'setting' => 'app_name', |
||
| 33 | 'prefix' => 'projects', |
||
| 34 | 'as' => 'projects.', |
||
| 35 | ], function ($router) { |
||
| 36 | $router->get('/', [ |
||
| 37 | 'as' => 'index', |
||
| 38 | 'uses' => 'ProjectsController@index', |
||
| 39 | ]); |
||
| 40 | $router->get('new', [ |
||
| 41 | 'as' => 'new', |
||
| 42 | 'uses' => 'ProjectsController@new', |
||
| 43 | ]); |
||
| 44 | $router->post('create', [ |
||
| 45 | 'as' => 'create', |
||
| 46 | 'uses' => 'ProjectsController@create', |
||
| 47 | ]); |
||
| 48 | |||
| 49 | |||
| 50 | }); |
||
| 51 | |||
| 52 | // Project Sub-routes |
||
| 53 | $router->group([ |
||
| 54 | 'middleware' => ['app.hasSetting'], |
||
| 55 | 'setting' => 'app_name', |
||
| 56 | 'as' => 'projects.', |
||
| 57 | ], function ($router) { |
||
| 58 | $router->get('{namespace}/{project}', [ |
||
| 59 | 'as' => 'project_show', |
||
| 60 | 'uses' => 'ProjectsController@show', |
||
| 61 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 62 | |||
| 63 | $router->get('{namespace}/{project}/edit', [ |
||
| 64 | 'as' => 'project_edit', |
||
| 65 | 'uses' => 'ProjectsController@edit', |
||
| 66 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 67 | $router->post('{namespace}/{project}/update', [ |
||
| 68 | 'as' => 'project_update', |
||
| 69 | 'uses' => 'ProjectsController@update', |
||
| 70 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 71 | |||
| 72 | |||
| 73 | //Issues |
||
| 74 | $router->get('{namespace}/{project}/issues', [ |
||
| 75 | 'as' => 'issue_index', |
||
| 76 | 'uses' => 'Projects\\IssuesController@index', |
||
| 77 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 78 | |||
| 79 | //new |
||
| 80 | $router->get('{namespace}/{project}/issues/new', [ |
||
| 81 | 'as' => 'issue_new', |
||
| 82 | 'uses' => 'Projects\\IssuesController@new', |
||
| 83 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 84 | |||
| 85 | //create |
||
| 86 | $router->post('{namespace}/{project}/issues', [ |
||
| 87 | 'as' => 'issue_create', |
||
| 88 | 'uses' => 'Projects\\IssuesController@create', |
||
| 89 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 90 | |||
| 91 | //show |
||
| 92 | $router->get('{namespace}/{project}/issues/{issue}', [ |
||
| 93 | 'as' => 'issue_show', |
||
| 94 | 'uses' => 'Projects\\IssuesController@show', |
||
| 95 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 96 | |||
| 97 | //update |
||
| 98 | $router->post('{namespace}/{project}/issues/{issue}', [ |
||
| 99 | 'as' => 'issue_update', |
||
| 100 | 'uses' => 'Projects\\IssuesController@update', |
||
| 101 | ])->where('namespace', '[a-zA-z.0-9_\-]+')->where('project', '[a-zA-z.0-9_\-]+'); |
||
| 102 | |||
| 103 | }); |
||
| 104 | |||
| 105 | |||
| 106 | } |
||
| 107 | } |
||
| 108 |