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