| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 173 | 
| Code Lines | 139 | 
| 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 | ||
| 148 | public function providesRequestsContainingInvalidParameters(): array | ||
| 149 |     { | ||
| 150 | $requestFactory = $this->getRequestFactory(); | ||
| 151 | |||
| 152 | $argLists = [[ | ||
| 153 | 'requestIsSuspicious' => false, | ||
| 154 | 'request' => $requestFactory->createGet([]), | ||
| 155 | 'selector' => ['id'], //Specific parameters. | ||
| 156 | 'validator' => '/^\d*$/', | ||
| 157 | 'options' => [], | ||
| 158 | ], [ | ||
| 159 | 'requestIsSuspicious' => false, | ||
| 160 | 'request' => $requestFactory->createPost([]), | ||
| 161 | 'selector' => ['id'], //Specific parameters. | ||
| 162 | 'validator' => '/^\d*$/', | ||
| 163 | 'options' => [], | ||
| 164 | ], [ | ||
| 165 | 'requestIsSuspicious' => false, | ||
| 166 | 'request' => $requestFactory->createGet(['id' => '123']), | ||
| 167 | 'selector' => ['id'], //Specific parameters. | ||
| 168 | 'validator' => '/^\d*$/', | ||
| 169 | 'options' => [], | ||
| 170 | ], [ | ||
| 171 | 'requestIsSuspicious' => false, | ||
| 172 | 'request' => $requestFactory->createPost(['id' => '123']), | ||
| 173 | 'selector' => ['id'], //Specific parameters. | ||
| 174 | 'validator' => '/^\d*$/', | ||
| 175 | 'options' => [], | ||
| 176 | ], [ | ||
| 177 | 'requestIsSuspicious' => false, | ||
| 178 | 'request' => $requestFactory->createGet(['id' => '']), | ||
| 179 | 'selector' => ['id'], //Specific parameters. | ||
| 180 | 'validator' => '/^\d*$/', | ||
| 181 | 'options' => [], | ||
| 182 | ], [ | ||
| 183 | 'requestIsSuspicious' => false, | ||
| 184 | 'request' => $requestFactory->createPost(['id' => '']), | ||
| 185 | 'selector' => ['id'], //Specific parameters. | ||
| 186 | 'validator' => '/^\d*$/', | ||
| 187 | 'options' => [], | ||
| 188 | ], [ | ||
| 189 | 'requestIsSuspicious' => false, | ||
| 190 | 'request' => $requestFactory->createGet([]), | ||
| 191 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 192 | 'validator' => '/^\d*$/', | ||
| 193 | 'options' => [], | ||
| 194 | ], [ | ||
| 195 | 'requestIsSuspicious' => false, | ||
| 196 | 'request' => $requestFactory->createPost([]), | ||
| 197 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 198 | 'validator' => '/^\d*$/', | ||
| 199 | 'options' => [], | ||
| 200 | ], [ | ||
| 201 | 'requestIsSuspicious' => false, | ||
| 202 | 'request' => $requestFactory->createGet(['valid_id' => '123']), | ||
| 203 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 204 | 'validator' => '/^\d*$/', | ||
| 205 | 'options' => [], | ||
| 206 | ], [ | ||
| 207 | 'requestIsSuspicious' => false, | ||
| 208 | 'request' => $requestFactory->createPost(['valid_id' => '123']), | ||
| 209 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 210 | 'validator' => '/^\d*$/', | ||
| 211 | 'options' => [], | ||
| 212 | ], [ | ||
| 213 | 'requestIsSuspicious' => false, | ||
| 214 | 'request' => $requestFactory->createGet(['id' => ['123', '456']]), // As in `?id[]=123&id[]=456` | ||
| 215 | 'selector' => ['id'], //Specific parameters. | ||
| 216 | 'validator' => '/^\d*$/', | ||
| 217 | 'options' => [], | ||
| 218 | ], [ | ||
| 219 | 'requestIsSuspicious' => false, | ||
| 220 | 'request' => $requestFactory->createPost(['id' => ['123', '456']]), // As in `?id[]=123&id[]=456`. | ||
| 221 | 'selector' => ['id'], //Specific parameters. | ||
| 222 | 'validator' => '/^\d*$/', | ||
| 223 | 'options' => [], | ||
| 224 | ], [ | ||
| 225 | 'requestIsSuspicious' => false, | ||
| 226 | 'request' => $requestFactory->createGet(['valid_id' => ['123', '456']]), // As in `?id[]=123&id[]=456`. | ||
| 227 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 228 | 'validator' => '/^\d*$/', | ||
| 229 | 'options' => [], | ||
| 230 | ], [ | ||
| 231 | 'requestIsSuspicious' => false, | ||
| 232 | 'request' => $requestFactory->createPost(['valid_id' => ['123', '456']]), // As in `?id[]=123&id[]=456`. | ||
| 233 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 234 | 'validator' => '/^\d*$/', | ||
| 235 | 'options' => [], | ||
| 236 | ], [ | ||
| 237 | 'requestIsSuspicious' => true, | ||
| 238 | 'request' => $requestFactory->createGet(['id' => "71094'A=0"]), | ||
| 239 | 'selector' => ['id'], //Specific parameters. | ||
| 240 | 'validator' => '/^\d*$/', | ||
| 241 | 'options' => [], | ||
| 242 | ], [ | ||
| 243 | 'requestIsSuspicious' => true, | ||
| 244 | 'request' => $requestFactory->createPost(['id' => "71094'A=0"]), | ||
| 245 | 'selector' => ['id'], //Specific parameters. | ||
| 246 | 'validator' => '/^\d*$/', | ||
| 247 | 'options' => [], | ||
| 248 | ], [ | ||
| 249 | 'requestIsSuspicious' => true, | ||
| 250 | 'request' => $requestFactory->createGet(['invalid_id' => "71094'A=0"]), | ||
| 251 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 252 | 'validator' => '/^\d*$/', | ||
| 253 | 'options' => [], | ||
| 254 | ], [ | ||
| 255 | 'requestIsSuspicious' => true, | ||
| 256 | 'request' => $requestFactory->createPost(['invalid_id' => "71094'A=0"]), | ||
| 257 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 258 | 'validator' => '/^\d*$/', | ||
| 259 | 'options' => [], | ||
| 260 | ], [ | ||
| 261 | 'requestIsSuspicious' => true, | ||
| 262 | 'request' => $requestFactory->createGet(['id' => ['123', "71094'A=0"]]), // As in `?id[]=123&id[]=71094%27A%3D0`. | ||
| 263 | 'selector' => ['id'], //Specific parameters. | ||
| 264 | 'validator' => '/^\d*$/', | ||
| 265 | 'options' => [], | ||
| 266 | ], [ | ||
| 267 | 'requestIsSuspicious' => true, | ||
| 268 | 'request' => $requestFactory->createPost(['id' => ['123', "71094'A=0"]]), // As in `?id[]=123&id[]=71094%27A%3D0`. | ||
| 269 | 'selector' => ['id'], //Specific parameters. | ||
| 270 | 'validator' => '/^\d*$/', | ||
| 271 | 'options' => [], | ||
| 272 | ], [ | ||
| 273 | 'requestIsSuspicious' => true, | ||
| 274 | 'request' => $requestFactory->createGet(['invalid_id' => ['123', "71094'A=0"]]), // As in `?id[]=123&id[]=71094%27A%3D0`. | ||
| 275 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 276 | 'validator' => '/^\d*$/', | ||
| 277 | 'options' => [], | ||
| 278 | ], [ | ||
| 279 | 'requestIsSuspicious' => true, | ||
| 280 | 'request' => $requestFactory->createPost(['invalid_id' => ['123', "71094'A=0"]]), // As in `?id[]=123&id[]=71094%27A%3D0`. | ||
| 281 | 'selector' => '/_id$/', //All parameters with names matching a regex. | ||
| 282 | 'validator' => '/^\d*$/', | ||
| 283 | 'options' => [], | ||
| 284 | ], [ | ||
| 285 | 'requestIsSuspicious' => true, | ||
| 286 | 'request' => $requestFactory->createGet(['array_of_valid_ids' => ['123']]), // As in `?array_of_valid_ids[]=123`. | ||
| 287 | 'selector' => ['array_of_valid_ids'], | ||
| 288 | 'validator' => '/^\d*$/', | ||
| 289 | 'options' => ['type' => 'string'], | ||
| 290 | ], [ | ||
| 291 | 'requestIsSuspicious' => true, | ||
| 292 | 'request' => $requestFactory->createPost(['array_of_valid_ids' => ['123']]), // As in `?array_of_valid_ids[]=123`. | ||
| 293 | 'selector' => ['array_of_valid_ids'], | ||
| 294 | 'validator' => '/^\d*$/', | ||
| 295 | 'options' => ['type' => 'string'], | ||
| 296 | ]]; | ||
| 297 | |||
| 298 | $getRequest = $requestFactory->createGet(); | ||
| 299 |         $getRequest->query->set('1564736436', '');  // The query string was `?1564736436=` | ||
| 300 | |||
| 301 | $argLists[] = [ | ||
| 302 | 'requestIsSuspicious' => false, | ||
| 303 | 'request' => $getRequest, | ||
| 304 | 'selector' => '/_id$/', // All parameters with names matching a regex | ||
| 305 | 'validator' => '/^\d*$/', | ||
| 306 | 'options' => [], | ||
| 307 | ]; | ||
| 308 | |||
| 309 | $postRequest = $requestFactory->createPost(); | ||
| 310 |         $postRequest->request->set('1564736436', '');  // The query string was `?1564736436=` | ||
| 311 | |||
| 312 | $argLists[] = [ | ||
| 313 | 'requestIsSuspicious' => false, | ||
| 314 | 'request' => $postRequest, | ||
| 315 | 'selector' => '/_id$/', // All parameters with names matching a regex | ||
| 316 | 'validator' => '/^\d*$/', | ||
| 317 | 'options' => [], | ||
| 318 | ]; | ||
| 319 | |||
| 320 | return $argLists; | ||
| 321 | } | ||
| 507 |