Conditions | 1 |
Paths | 1 |
Total Lines | 155 |
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 // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase |
||
292 | public function get_access_token_data_provider() { |
||
293 | return array( |
||
294 | 'no tokens' => array( |
||
295 | false, // blog token. |
||
296 | false, // user tokens. |
||
297 | false, // master_user. |
||
298 | false, // user_id_query. |
||
299 | false, // token_key_query. |
||
300 | 'no_possible_tokens', // expected error code. |
||
301 | false, // expected token. |
||
302 | ), |
||
303 | 'no tokens' => array( |
||
304 | false, // blog token. |
||
305 | false, // user tokens. |
||
306 | false, // master_user. |
||
307 | 22, // user_id_query. |
||
308 | false, // token_key_query. |
||
309 | 'no_user_tokens', // expected error code. |
||
310 | false, // expected token. |
||
311 | ), |
||
312 | 'no tokens for the user' => array( |
||
313 | false, // blog token. |
||
314 | array( |
||
315 | 11 => 'asd.zxc.11', |
||
316 | ), // user tokens. |
||
317 | false, // master_user. |
||
318 | 22, // user_id_query. |
||
319 | false, // token_key_query. |
||
320 | 'no_token_for_user', // expected error code. |
||
321 | false, // expected token. |
||
322 | ), |
||
323 | 'malformed user token' => array( |
||
324 | false, // blog token. |
||
325 | array( |
||
326 | 11 => 'asdzxc.11', |
||
327 | ), // user tokens. |
||
328 | false, // master_user. |
||
329 | 11, // user_id_query. |
||
330 | false, // token_key_query. |
||
331 | 'token_malformed', // expected error code. |
||
332 | false, // expected token. |
||
333 | ), |
||
334 | 'user mismatch' => array( |
||
335 | false, // blog token. |
||
336 | array( |
||
337 | 11 => 'asd.zxc.22', |
||
338 | ), // user tokens. |
||
339 | false, // master_user. |
||
340 | 11, // user_id_query. |
||
341 | false, // token_key_query. |
||
342 | 'user_id_mismatch', // expected error code. |
||
343 | false, // expected token. |
||
344 | ), |
||
345 | 'Connection owner not defined' => array( |
||
346 | false, // blog token. |
||
347 | array( |
||
348 | 11 => 'asd.zxc.11', |
||
349 | ), // user tokens. |
||
350 | false, // master_user. |
||
351 | 'CONNECTION_OWNER', // user_id_query. |
||
352 | false, // token_key_query. |
||
353 | 'empty_master_user_option', // expected error code. |
||
354 | false, // expected token. |
||
355 | ), |
||
356 | 'Connection owner' => array( |
||
357 | false, // blog token. |
||
358 | array( |
||
359 | 11 => 'asd.zxc.11', |
||
360 | ), // user tokens. |
||
361 | 11, // master_user. |
||
362 | 'CONNECTION_OWNER', // user_id_query. |
||
363 | false, // token_key_query. |
||
364 | false, // expected error code. |
||
365 | (object) array( |
||
366 | 'secret' => 'asd.zxc', |
||
367 | 'external_user_id' => 11, |
||
368 | ), // expected token. |
||
369 | ), |
||
370 | 'Find blog token' => array( |
||
371 | 'asdasd.qweqwe', // blog token. |
||
372 | false, // user tokens. |
||
373 | false, // master_user. |
||
374 | false, // user_id_query. |
||
375 | false, // token_key_query. |
||
376 | false, // expected error code. |
||
377 | (object) array( |
||
378 | 'secret' => 'asdasd.qweqwe', |
||
379 | 'external_user_id' => 0, |
||
380 | ), // expected token. |
||
381 | ), |
||
382 | 'Find user token' => array( |
||
383 | false, // blog token. |
||
384 | array( |
||
385 | 11 => 'qwe.asd.11', |
||
386 | 12 => 'asd.zxc.12', |
||
387 | ), // user tokens. |
||
388 | false, // master_user. |
||
389 | 11, // user_id_query. |
||
390 | false, // token_key_query. |
||
391 | false, // expected error code. |
||
392 | (object) array( |
||
393 | 'secret' => 'qwe.asd', |
||
394 | 'external_user_id' => 11, |
||
395 | ), // expected token. |
||
396 | ), |
||
397 | 'Find user token with secret' => array( |
||
398 | false, // blog token. |
||
399 | array( |
||
400 | 11 => 'qwe.asd.11', |
||
401 | 12 => 'asd.zxc.12', |
||
402 | ), // user tokens. |
||
403 | false, // master_user. |
||
404 | 12, // user_id_query. |
||
405 | 'asd', // token_key_query. |
||
406 | false, // expected error code. |
||
407 | (object) array( |
||
408 | 'secret' => 'asd.zxc', |
||
409 | 'external_user_id' => 12, |
||
410 | ), // expected token. |
||
411 | ), |
||
412 | 'Find blog token with secret' => array( |
||
413 | 'asdasd.qweqwe', // blog token. |
||
414 | false, // user tokens. |
||
415 | false, // master_user. |
||
416 | false, // user_id_query. |
||
417 | 'asdasd', // token_key_query. |
||
418 | false, // expected error code. |
||
419 | (object) array( |
||
420 | 'secret' => 'asdasd.qweqwe', |
||
421 | 'external_user_id' => 0, |
||
422 | ), // expected token. |
||
423 | ), |
||
424 | 'Dont find user token with secret' => array( |
||
425 | false, // blog token. |
||
426 | array( |
||
427 | 11 => 'qwe.asd.11', |
||
428 | 12 => 'asd.zxc.12', |
||
429 | ), // user tokens. |
||
430 | false, // master_user. |
||
431 | 12, // user_id_query. |
||
432 | 'qqq', // token_key_query. |
||
433 | 'no_valid_user_token', // expected error code. |
||
434 | false, // expected token. |
||
435 | ), |
||
436 | 'Dont find blog token with secret' => array( |
||
437 | 'asdasd.qweqwe', // blog token. |
||
438 | false, // user tokens. |
||
439 | false, // master_user. |
||
440 | false, // user_id_query. |
||
441 | 'kaasdas', // token_key_query. |
||
442 | 'no_valid_blog_token', // expected error code. |
||
443 | false, // expected token. |
||
444 | ), |
||
445 | ); |
||
446 | } |
||
447 | |||
457 |