| Conditions | 9 |
| Paths | 8 |
| Total Lines | 54 |
| Code Lines | 32 |
| 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 |
||
| 49 | public function indexAction(Request $request, $project = null, $type = null) |
||
| 50 | { |
||
| 51 | if ($request->get('projecttype') |
||
| 52 | && (strpos($request->get('projecttype'), '|') !== false) |
||
| 53 | ) { |
||
| 54 | $projectType = explode('|', $request->get('projecttype'), 2); |
||
| 55 | $projectQuery = $projectType[0]; |
||
| 56 | $typeQuery = $projectType[1]; |
||
| 57 | } else { |
||
| 58 | $projectQuery = $request->get('project'); |
||
| 59 | $typeQuery = $request->get('type'); |
||
| 60 | } |
||
| 61 | |||
| 62 | $username = $request->get('username'); |
||
| 63 | |||
| 64 | if ($projectQuery != '' && $typeQuery != '' && $username != '') { |
||
| 65 | return $this->redirectToRoute( |
||
| 66 | 'rfxAnalysisResult', |
||
| 67 | [ |
||
| 68 | 'project' => $projectQuery, |
||
| 69 | 'type' => $typeQuery, |
||
| 70 | 'username' => $username |
||
| 71 | ] |
||
| 72 | ); |
||
| 73 | } elseif ($projectQuery != '' && $typeQuery != '') { |
||
| 74 | return $this->redirectToRoute( |
||
| 75 | 'rfxAnalysisProjectType', |
||
| 76 | [ |
||
| 77 | 'project' => $projectQuery, |
||
| 78 | 'type' => $typeQuery |
||
| 79 | ] |
||
| 80 | ); |
||
| 81 | } |
||
| 82 | |||
| 83 | $rfx = $this->getParameter('rfx'); |
||
| 84 | |||
| 85 | $projectFields = []; |
||
| 86 | |||
| 87 | foreach (array_keys($rfx) as $row) { |
||
| 88 | $projectFields[$row] = $rfx[$row]['pages']; |
||
| 89 | } |
||
| 90 | |||
| 91 | // replace this example code with whatever you need |
||
| 92 | return $this->render( |
||
| 93 | 'rfxAnalysis/index.html.twig', |
||
| 94 | [ |
||
| 95 | 'xtPageTitle' => 'tool-rfx', |
||
| 96 | 'xtSubtitle' => 'tool-rfx-desc', |
||
| 97 | 'xtPage' => 'rfx', |
||
| 98 | 'project' => $projectQuery, |
||
| 99 | 'available' => $projectFields, |
||
| 100 | ] |
||
| 101 | ); |
||
| 102 | } |
||
| 103 | |||
| 203 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.