| 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 |
||
| 253 | public function get_access_token_data_provider() { |
||
| 254 | return array( |
||
| 255 | 'no tokens' => array( |
||
| 256 | false, // blog token. |
||
| 257 | false, // user tokens. |
||
| 258 | false, // master_user. |
||
| 259 | false, // user_id_query. |
||
| 260 | false, // token_key_query. |
||
| 261 | 'no_possible_tokens', // expected error code. |
||
| 262 | false, // expected token. |
||
| 263 | ), |
||
| 264 | 'no tokens' => array( |
||
| 265 | false, // blog token. |
||
| 266 | false, // user tokens. |
||
| 267 | false, // master_user. |
||
| 268 | 22, // user_id_query. |
||
| 269 | false, // token_key_query. |
||
| 270 | 'no_user_tokens', // expected error code. |
||
| 271 | false, // expected token. |
||
| 272 | ), |
||
| 273 | 'no tokens for the user' => array( |
||
| 274 | false, // blog token. |
||
| 275 | array( |
||
| 276 | 11 => 'asd.zxc.11', |
||
| 277 | ), // user tokens. |
||
| 278 | false, // master_user. |
||
| 279 | 22, // user_id_query. |
||
| 280 | false, // token_key_query. |
||
| 281 | 'no_token_for_user', // expected error code. |
||
| 282 | false, // expected token. |
||
| 283 | ), |
||
| 284 | 'malformed user token' => array( |
||
| 285 | false, // blog token. |
||
| 286 | array( |
||
| 287 | 11 => 'asdzxc.11', |
||
| 288 | ), // user tokens. |
||
| 289 | false, // master_user. |
||
| 290 | 11, // user_id_query. |
||
| 291 | false, // token_key_query. |
||
| 292 | 'token_malformed', // expected error code. |
||
| 293 | false, // expected token. |
||
| 294 | ), |
||
| 295 | 'user mismatch' => array( |
||
| 296 | false, // blog token. |
||
| 297 | array( |
||
| 298 | 11 => 'asd.zxc.22', |
||
| 299 | ), // user tokens. |
||
| 300 | false, // master_user. |
||
| 301 | 11, // user_id_query. |
||
| 302 | false, // token_key_query. |
||
| 303 | 'user_id_mismatch', // expected error code. |
||
| 304 | false, // expected token. |
||
| 305 | ), |
||
| 306 | 'Connection owner not defined' => array( |
||
| 307 | false, // blog token. |
||
| 308 | array( |
||
| 309 | 11 => 'asd.zxc.11', |
||
| 310 | ), // user tokens. |
||
| 311 | false, // master_user. |
||
| 312 | 'CONNECTION_OWNER', // user_id_query. |
||
| 313 | false, // token_key_query. |
||
| 314 | 'empty_master_user_option', // expected error code. |
||
| 315 | false, // expected token. |
||
| 316 | ), |
||
| 317 | 'Connection owner' => array( |
||
| 318 | false, // blog token. |
||
| 319 | array( |
||
| 320 | 11 => 'asd.zxc.11', |
||
| 321 | ), // user tokens. |
||
| 322 | 11, // master_user. |
||
| 323 | 'CONNECTION_OWNER', // user_id_query. |
||
| 324 | false, // token_key_query. |
||
| 325 | false, // expected error code. |
||
| 326 | (object) array( |
||
| 327 | 'secret' => 'asd.zxc', |
||
| 328 | 'external_user_id' => 11, |
||
| 329 | ), // expected token. |
||
| 330 | ), |
||
| 331 | 'Find blog token' => array( |
||
| 332 | 'asdasd.qweqwe', // blog token. |
||
| 333 | false, // user tokens. |
||
| 334 | false, // master_user. |
||
| 335 | false, // user_id_query. |
||
| 336 | false, // token_key_query. |
||
| 337 | false, // expected error code. |
||
| 338 | (object) array( |
||
| 339 | 'secret' => 'asdasd.qweqwe', |
||
| 340 | 'external_user_id' => 0, |
||
| 341 | ), // expected token. |
||
| 342 | ), |
||
| 343 | 'Find user token' => array( |
||
| 344 | false, // blog token. |
||
| 345 | array( |
||
| 346 | 11 => 'qwe.asd.11', |
||
| 347 | 12 => 'asd.zxc.12', |
||
| 348 | ), // user tokens. |
||
| 349 | false, // master_user. |
||
| 350 | 11, // user_id_query. |
||
| 351 | false, // token_key_query. |
||
| 352 | false, // expected error code. |
||
| 353 | (object) array( |
||
| 354 | 'secret' => 'qwe.asd', |
||
| 355 | 'external_user_id' => 11, |
||
| 356 | ), // expected token. |
||
| 357 | ), |
||
| 358 | 'Find user token with secret' => array( |
||
| 359 | false, // blog token. |
||
| 360 | array( |
||
| 361 | 11 => 'qwe.asd.11', |
||
| 362 | 12 => 'asd.zxc.12', |
||
| 363 | ), // user tokens. |
||
| 364 | false, // master_user. |
||
| 365 | 12, // user_id_query. |
||
| 366 | 'asd', // token_key_query. |
||
| 367 | false, // expected error code. |
||
| 368 | (object) array( |
||
| 369 | 'secret' => 'asd.zxc', |
||
| 370 | 'external_user_id' => 12, |
||
| 371 | ), // expected token. |
||
| 372 | ), |
||
| 373 | 'Find blog token with secret' => array( |
||
| 374 | 'asdasd.qweqwe', // blog token. |
||
| 375 | false, // user tokens. |
||
| 376 | false, // master_user. |
||
| 377 | false, // user_id_query. |
||
| 378 | 'asdasd', // token_key_query. |
||
| 379 | false, // expected error code. |
||
| 380 | (object) array( |
||
| 381 | 'secret' => 'asdasd.qweqwe', |
||
| 382 | 'external_user_id' => 0, |
||
| 383 | ), // expected token. |
||
| 384 | ), |
||
| 385 | 'Dont find user token with secret' => array( |
||
| 386 | false, // blog token. |
||
| 387 | array( |
||
| 388 | 11 => 'qwe.asd.11', |
||
| 389 | 12 => 'asd.zxc.12', |
||
| 390 | ), // user tokens. |
||
| 391 | false, // master_user. |
||
| 392 | 12, // user_id_query. |
||
| 393 | 'qqq', // token_key_query. |
||
| 394 | 'no_valid_user_token', // expected error code. |
||
| 395 | false, // expected token. |
||
| 396 | ), |
||
| 397 | 'Dont find blog token with secret' => array( |
||
| 398 | 'asdasd.qweqwe', // blog token. |
||
| 399 | false, // user tokens. |
||
| 400 | false, // master_user. |
||
| 401 | false, // user_id_query. |
||
| 402 | 'kaasdas', // token_key_query. |
||
| 403 | 'no_valid_blog_token', // expected error code. |
||
| 404 | false, // expected token. |
||
| 405 | ), |
||
| 406 | ); |
||
| 407 | } |
||
| 408 | |||
| 410 |