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