| Conditions | 1 |
| Paths | 1 |
| Total Lines | 199 |
| Lines | 47 |
| Ratio | 23.62 % |
| Changes | 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 |
||
| 20 | private function registerRoutes(Container $di, App $app) |
||
| 21 | { |
||
| 22 | $app->error(static function (Exception $e) use ($di, $app) { |
||
| 23 | /** @var Twig $view */ |
||
| 24 | $view = $di['view']; |
||
| 25 | $view->parserOptions['cache'] = false; |
||
| 26 | $view->parserExtensions = [ |
||
|
|
|||
| 27 | new TwigExtension($app), |
||
| 28 | ]; |
||
| 29 | |||
| 30 | // Remove the controller so we don't render it. |
||
| 31 | unset($app->controller); |
||
| 32 | |||
| 33 | $app->view($view); |
||
| 34 | $app->render('error/view.twig', [ |
||
| 35 | 'message' => $e->getMessage(), |
||
| 36 | 'stack_trace' => $e->getTraceAsString(), |
||
| 37 | ]); |
||
| 38 | }); |
||
| 39 | |||
| 40 | // Profile Runs routes |
||
| 41 | $app->get('/', static function () use ($di, $app) { |
||
| 42 | /** @var Controller\RunController $controller */ |
||
| 43 | $controller = $app->controller = $di['runController']; |
||
| 44 | $request = $app->request(); |
||
| 45 | $response = $app->response(); |
||
| 46 | |||
| 47 | $controller->index($request, $response); |
||
| 48 | })->setName('home'); |
||
| 49 | |||
| 50 | View Code Duplication | $app->get('/run/view', static function () use ($di, $app) { |
|
| 51 | /** @var Controller\RunController $controller */ |
||
| 52 | $controller = $app->controller = $di['runController']; |
||
| 53 | $request = $app->request(); |
||
| 54 | $response = $app->response(); |
||
| 55 | |||
| 56 | $controller->view($request, $response); |
||
| 57 | })->setName('run.view'); |
||
| 58 | |||
| 59 | $app->get('/run/delete', static function () use ($di, $app) { |
||
| 60 | /** @var Controller\RunController $controller */ |
||
| 61 | $controller = $app->controller = $di['runController']; |
||
| 62 | $request = $app->request(); |
||
| 63 | |||
| 64 | $controller->deleteForm($request); |
||
| 65 | })->setName('run.delete.form'); |
||
| 66 | |||
| 67 | $app->post('/run/delete', static function () use ($di, $app) { |
||
| 68 | /** @var Controller\RunController $controller */ |
||
| 69 | $controller = $di['runController']; |
||
| 70 | $request = $app->request(); |
||
| 71 | |||
| 72 | $controller->deleteSubmit($request); |
||
| 73 | })->setName('run.delete.submit'); |
||
| 74 | |||
| 75 | $app->get('/run/delete_all', static function () use ($di, $app) { |
||
| 76 | /** @var Controller\RunController $controller */ |
||
| 77 | $controller = $app->controller = $di['runController']; |
||
| 78 | $controller->deleteAllForm(); |
||
| 79 | })->setName('run.deleteAll.form'); |
||
| 80 | |||
| 81 | $app->post('/run/delete_all', static function () use ($di) { |
||
| 82 | /** @var Controller\RunController $controller */ |
||
| 83 | $controller = $di['runController']; |
||
| 84 | $controller->deleteAllSubmit(); |
||
| 85 | })->setName('run.deleteAll.submit'); |
||
| 86 | |||
| 87 | View Code Duplication | $app->get('/url/view', static function () use ($di, $app) { |
|
| 88 | /** @var Controller\RunController $controller */ |
||
| 89 | $controller = $app->controller = $di['runController']; |
||
| 90 | $request = $app->request(); |
||
| 91 | |||
| 92 | $controller->url($request); |
||
| 93 | })->setName('url.view'); |
||
| 94 | |||
| 95 | $app->get('/run/compare', static function () use ($di, $app) { |
||
| 96 | /** @var Controller\RunController $controller */ |
||
| 97 | $controller = $app->controller = $di['runController']; |
||
| 98 | $request = $app->request(); |
||
| 99 | |||
| 100 | $controller->compare($request); |
||
| 101 | })->setName('run.compare'); |
||
| 102 | |||
| 103 | $app->get('/run/symbol', static function () use ($di, $app) { |
||
| 104 | /** @var Controller\RunController $controller */ |
||
| 105 | $controller = $app->controller = $di['runController']; |
||
| 106 | $request = $app->request(); |
||
| 107 | |||
| 108 | $controller->symbol($request); |
||
| 109 | })->setName('run.symbol'); |
||
| 110 | |||
| 111 | $app->get('/run/symbol/short', static function () use ($di, $app) { |
||
| 112 | /** @var Controller\RunController $controller */ |
||
| 113 | $controller = $app->controller = $di['runController']; |
||
| 114 | $request = $app->request(); |
||
| 115 | |||
| 116 | $controller->symbolShort($request); |
||
| 117 | })->setName('run.symbol-short'); |
||
| 118 | |||
| 119 | $app->get('/run/callgraph', static function () use ($di, $app) { |
||
| 120 | /** @var Controller\RunController $controller */ |
||
| 121 | $controller = $app->controller = $di['runController']; |
||
| 122 | $request = $app->request(); |
||
| 123 | |||
| 124 | $controller->callgraph($request); |
||
| 125 | })->setName('run.callgraph'); |
||
| 126 | |||
| 127 | View Code Duplication | $app->get('/run/callgraph/data', static function () use ($di, $app) { |
|
| 128 | /** @var Controller\RunController $controller */ |
||
| 129 | $controller = $di['runController']; |
||
| 130 | $request = $app->request(); |
||
| 131 | $response = $app->response(); |
||
| 132 | |||
| 133 | $controller->callgraphData($request, $response); |
||
| 134 | })->setName('run.callgraph.data'); |
||
| 135 | |||
| 136 | View Code Duplication | $app->get('/run/callgraph/dot', static function () use ($di, $app) { |
|
| 137 | /** @var Controller\RunController $controller */ |
||
| 138 | $controller = $di['runController']; |
||
| 139 | $request = $app->request(); |
||
| 140 | $response = $app->response(); |
||
| 141 | |||
| 142 | $controller->callgraphDataDot($request, $response); |
||
| 143 | })->setName('run.callgraph.dot'); |
||
| 144 | |||
| 145 | // Import route |
||
| 146 | $app->post('/run/import', static function () use ($di, $app) { |
||
| 147 | /** @var Controller\ImportController $controller */ |
||
| 148 | $controller = $di['importController']; |
||
| 149 | $request = $app->request(); |
||
| 150 | $response = $app->response(); |
||
| 151 | |||
| 152 | $controller->import($request, $response); |
||
| 153 | })->setName('run.import'); |
||
| 154 | |||
| 155 | // Watch function routes. |
||
| 156 | $app->get('/watch', static function () use ($di, $app) { |
||
| 157 | /** @var Controller\WatchController $controller */ |
||
| 158 | $controller = $app->controller = $di['watchController']; |
||
| 159 | $controller->get(); |
||
| 160 | })->setName('watch.list'); |
||
| 161 | |||
| 162 | $app->post('/watch', static function () use ($di, $app) { |
||
| 163 | /** @var Controller\WatchController $controller */ |
||
| 164 | $controller = $di['watchController']; |
||
| 165 | $request = $app->request(); |
||
| 166 | |||
| 167 | $controller->post($request); |
||
| 168 | })->setName('watch.save'); |
||
| 169 | |||
| 170 | // Custom report routes. |
||
| 171 | $app->get('/custom', static function () use ($di, $app) { |
||
| 172 | /** @var Controller\CustomController $controller */ |
||
| 173 | $controller = $app->controller = $di['customController']; |
||
| 174 | $controller->get(); |
||
| 175 | })->setName('custom.view'); |
||
| 176 | |||
| 177 | $app->get('/custom/help', static function () use ($di, $app) { |
||
| 178 | /** @var Controller\CustomController $controller */ |
||
| 179 | $controller = $app->controller = $di['customController']; |
||
| 180 | $request = $app->request(); |
||
| 181 | |||
| 182 | $controller->help($request); |
||
| 183 | })->setName('custom.help'); |
||
| 184 | |||
| 185 | View Code Duplication | $app->post('/custom/query', static function () use ($di, $app) { |
|
| 186 | /** @var Controller\CustomController $controller */ |
||
| 187 | $controller = $di['customController']; |
||
| 188 | $request = $app->request(); |
||
| 189 | $response = $app->response(); |
||
| 190 | |||
| 191 | $controller->query($request, $response); |
||
| 192 | })->setName('custom.query'); |
||
| 193 | |||
| 194 | // Waterfall routes |
||
| 195 | $app->get('/waterfall', static function () use ($di, $app) { |
||
| 196 | /** @var Controller\WaterfallController $controller */ |
||
| 197 | $controller = $app->controller = $di['waterfallController']; |
||
| 198 | $controller->index(); |
||
| 199 | })->setName('waterfall.list'); |
||
| 200 | |||
| 201 | View Code Duplication | $app->get('/waterfall/data', static function () use ($di, $app) { |
|
| 202 | /** @var Controller\WaterfallController $controller */ |
||
| 203 | $controller = $di['waterfallController']; |
||
| 204 | $request = $app->request(); |
||
| 205 | $response = $app->response(); |
||
| 206 | |||
| 207 | $controller->query($request, $response); |
||
| 208 | })->setName('waterfall.data'); |
||
| 209 | |||
| 210 | // Metrics |
||
| 211 | $app->get('/metrics', static function () use ($di, $app) { |
||
| 212 | /** @var Controller\MetricsController $controller */ |
||
| 213 | $controller = $di['metricsController']; |
||
| 214 | $response = $app->response(); |
||
| 215 | |||
| 216 | $controller->metrics($response); |
||
| 217 | })->setName('metrics'); |
||
| 218 | } |
||
| 219 | } |
||
| 220 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..