Conditions | 18 |
Paths | 94 |
Total Lines | 49 |
Code Lines | 30 |
Lines | 30 |
Ratio | 61.22 % |
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 |
||
106 | public function process(Request $request, RequestHandlerInterface $handler): ResponseInterface |
||
107 | { |
||
108 | // Check if there is a limit of input number in php |
||
109 | // Throw exception if the limit is reached |
||
110 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.get.max_vars')) { |
|
111 | $maxGet = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.get.max_vars')); |
||
112 | if ($maxGet !== null) { |
||
113 | $this->count = 0; |
||
114 | array_walk_recursive($_GET, array($this, 'countRecursive')); |
||
115 | if ($this->count === $maxGet) { |
||
116 | 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.'); |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.post.max_vars')) { |
|
121 | $maxPost = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.post.max_vars')); |
||
122 | if ($maxPost !== null) { |
||
123 | $this->count = 0; |
||
124 | array_walk_recursive($_POST, array($this, 'countRecursive')); |
||
125 | if ($this->count === $maxPost) { |
||
126 | 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.'); |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | View Code Duplication | if (ini_get('max_input_vars') || ini_get('suhosin.request.max_vars')) { |
|
131 | $maxRequest = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.request.max_vars')); |
||
132 | if ($maxRequest !== null) { |
||
133 | $this->count = 0; |
||
134 | array_walk_recursive($_REQUEST, array($this, 'countRecursive')); |
||
135 | if ($this->count === $maxRequest) { |
||
136 | 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.'); |
||
137 | } |
||
138 | } |
||
139 | } |
||
140 | if (isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post' && empty($_POST) && empty($_FILES)) { |
||
141 | $maxPostSize = self::iniGetBytes('post_max_size'); |
||
142 | if ($_SERVER['CONTENT_LENGTH'] > $maxPostSize) { |
||
143 | throw new SplashException( |
||
144 | sprintf('Max post size exceeded! Got %s bytes, but limit is %s bytes. Edit post_max_size setting in your php.ini.', |
||
145 | $_SERVER['CONTENT_LENGTH'], |
||
146 | $maxPostSize |
||
147 | ) |
||
148 | ); |
||
149 | } |
||
150 | } |
||
151 | |||
152 | //If no Exception has been thrown, call next router |
||
153 | return $handler->handle($request); |
||
154 | } |
||
155 | } |
||
156 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.