| Conditions | 22 |
| Paths | 134 |
| Total Lines | 61 |
| Code Lines | 38 |
| Lines | 39 |
| Ratio | 63.93 % |
| Changes | 2 | ||
| 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 |
||
| 137 | public function __invoke(Request $request, Response $response, callable $out = null) |
||
| 138 | { |
||
| 139 | // Check if there is a limit of input number in php |
||
| 140 | // Throw exception if the limit is reached |
||
| 141 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.get.max_vars')) { |
|
| 142 | $maxGet = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.get.max_vars')); |
||
| 143 | if ($maxGet !== null) { |
||
| 144 | $this->count = 0; |
||
| 145 | array_walk_recursive($_GET, array($this, 'countRecursive')); |
||
| 146 | if ($this->count == $maxGet) { |
||
| 147 | if ($this->log != null) { |
||
| 148 | $this->log->error('Max input vars reaches for get parameters ({maxGet}). Check your variable max_input_vars in php.ini or suhosin module suhosin.get.max_vars.', ['maxGet' => $maxGet]); |
||
| 149 | } |
||
| 150 | throw new SplashException('Max input vars reaches for get parameters ('.$maxGet.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.get.max_vars.'); |
||
| 151 | } |
||
| 152 | } |
||
| 153 | } |
||
| 154 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.post.max_vars')) { |
|
| 155 | $maxPost = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.post.max_vars')); |
||
| 156 | if ($maxPost !== null) { |
||
| 157 | $this->count = 0; |
||
| 158 | array_walk_recursive($_POST, array($this, 'countRecursive')); |
||
| 159 | if ($this->count == $maxPost) { |
||
| 160 | if ($this->log != null) { |
||
| 161 | $this->log->error('Max input vars reaches for post parameters ({maxPost}). Check your variable max_input_vars in php.ini or suhosin module suhosin.post.max_vars.', ['maxPost' => $maxPost]); |
||
| 162 | } |
||
| 163 | throw new SplashException('Max input vars reaches for post parameters ('.$maxPost.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.post.max_vars.'); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | } |
||
| 167 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.request.max_vars')) { |
|
| 168 | $maxRequest = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.request.max_vars')); |
||
| 169 | if ($maxRequest !== null) { |
||
| 170 | $this->count = 0; |
||
| 171 | array_walk_recursive($_REQUEST, array($this, 'countRecursive')); |
||
| 172 | if ($this->count == $maxRequest) { |
||
| 173 | if ($this->log != null) { |
||
| 174 | $this->log->error('Max input vars reaches for request parameters ({maxRequest}). Check your variable max_input_vars in php.ini or suhosin module suhosin.request.max_vars.', ['maxRequest' => $maxRequest]); |
||
| 175 | } |
||
| 176 | throw new SplashException('Max input vars reaches for request parameters ('.$maxRequest.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.request.max_vars.'); |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 180 | if (isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post' && empty($_POST) && empty($_FILES)) { |
||
| 181 | $maxPostSize = self::iniGetBytes('post_max_size'); |
||
| 182 | if ($_SERVER['CONTENT_LENGTH'] > $maxPostSize) { |
||
| 183 | if ($this->log != null) { |
||
| 184 | $this->log->error('Max post size exceeded! Got {length} bytes, but limit is {maxPostSize} bytes. Edit post_max_size setting in your php.ini.', ['length' => $_SERVER['CONTENT_LENGTH'], 'maxPostSize' => $maxPostSize]); |
||
| 185 | } |
||
| 186 | throw new SplashException( |
||
| 187 | sprintf('Max post size exceeded! Got %s bytes, but limit is %s bytes. Edit post_max_size setting in your php.ini.', |
||
| 188 | $_SERVER['CONTENT_LENGTH'], |
||
| 189 | $maxPostSize |
||
| 190 | ) |
||
| 191 | ); |
||
| 192 | } |
||
| 193 | } |
||
| 194 | |||
| 195 | //If no Exception has been thrown, call next router |
||
| 196 | return $out($request, $response); |
||
| 197 | } |
||
| 198 | } |
||
| 199 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.