| Conditions | 10 |
| Paths | 11 |
| Total Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 77 | private function setGetVariables() |
||
| 78 | { |
||
| 79 | $globals_options = $this->options->getGlobals(); |
||
| 80 | |||
| 81 | // if we should not set any global vars, we can return safely |
||
| 82 | if (!$globals_options['get'] && !$globals_options['request']) { |
||
| 83 | return; |
||
| 84 | } |
||
| 85 | |||
| 86 | // check if $_GET is used at all (ini - variables_order ?) |
||
| 87 | // check if $_GET is written to $_REQUEST (ini - variables_order / request_order) |
||
| 88 | // depending on request_order, check if $_REQUEST is already written and decide if we are allowed to override |
||
| 89 | |||
| 90 | $request_order = ini_get('request_order'); |
||
| 91 | |||
| 92 | if ($request_order === false) { |
||
| 93 | $request_order = ini_get('variables_order'); |
||
| 94 | } |
||
| 95 | |||
| 96 | $get_prio = stripos($request_order, 'g'); |
||
| 97 | $post_prio = stripos($request_order, 'p'); |
||
| 98 | |||
| 99 | $forceOverrideRequest = $get_prio > $post_prio; |
||
| 100 | |||
| 101 | $routeParams = $this->getEvent()->getRouteMatch()->getParams(); |
||
| 102 | |||
| 103 | foreach ($routeParams as $paramName => $paramValue) { |
||
| 104 | if ($globals_options['get'] && !isset($_GET[$paramName])) { |
||
| 105 | $_GET[$paramName] = $paramValue; |
||
| 106 | } |
||
| 107 | |||
| 108 | if ($globals_options['request'] && ($forceOverrideRequest || !isset($_REQUEST[$paramName]))) { |
||
| 109 | $_REQUEST[$paramName] = $paramValue; |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 141 |