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