| Conditions | 1 |
| Paths | 1 |
| Total Lines | 147 |
| Code Lines | 72 |
| 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 |
||
| 317 | public function testSendOnlyDirty() |
||
| 318 | { |
||
| 319 | $mapping = $this->getMapping(); |
||
| 320 | $unitOfWork = $this->newTestedInstance($mapping); |
||
| 321 | |||
| 322 | $this |
||
| 323 | ->then |
||
| 324 | ->variable($unitOfWork->getDirtyData( |
||
| 325 | [ |
||
| 326 | '@id' => '/v12/carts/1', |
||
| 327 | 'cartItemList' => [ |
||
| 328 | [ |
||
| 329 | '@id' => '/v12/cart_items/1', |
||
| 330 | 'amount' => 2, |
||
| 331 | ], |
||
| 332 | [ |
||
| 333 | '@id' => '/v12/cart_items/2', |
||
| 334 | 'amount' => 1, |
||
| 335 | ], |
||
| 336 | ], |
||
| 337 | ], |
||
| 338 | [ |
||
| 339 | '@id' => '/v12/carts/1', |
||
| 340 | 'cartItemList' => [ |
||
| 341 | [ |
||
| 342 | '@id' => '/v12/cart_items/1', |
||
| 343 | 'amount' => 1, |
||
| 344 | ], |
||
| 345 | [ |
||
| 346 | '@id' => '/v12/cart_items/2', |
||
| 347 | 'amount' => 1, |
||
| 348 | ], |
||
| 349 | ], |
||
| 350 | ], |
||
| 351 | $this->getCartMetadata() |
||
| 352 | )) |
||
| 353 | ->isEqualTo( |
||
| 354 | [ |
||
| 355 | 'cartItemList' => [ |
||
| 356 | [ |
||
| 357 | '@id' => '/v12/cart_items/1', |
||
| 358 | 'amount' => 2, |
||
| 359 | ], |
||
| 360 | [ |
||
| 361 | '@id' => '/v12/cart_items/2', |
||
| 362 | ], |
||
| 363 | ], |
||
| 364 | ] |
||
| 365 | ) |
||
| 366 | ->then |
||
| 367 | ->variable($unitOfWork->getDirtyData( |
||
| 368 | [ |
||
| 369 | '@id' => '/v12/carts/1', |
||
| 370 | 'status' => 'ok', |
||
| 371 | 'clientPhoneNumber' => '+33123456789', |
||
| 372 | ], |
||
| 373 | [ |
||
| 374 | '@id' => '/v12/carts/1', |
||
| 375 | 'status' => 'ko', |
||
| 376 | 'clientPhoneNumber' => '+33123456789', |
||
| 377 | ], |
||
| 378 | $this->getCartMetadata() |
||
| 379 | )) |
||
| 380 | ->isEqualTo( |
||
| 381 | [ |
||
| 382 | 'status' => 'ok', |
||
| 383 | ] |
||
| 384 | ) |
||
| 385 | ->then |
||
| 386 | ->variable($unitOfWork->getDirtyData( |
||
| 387 | [ |
||
| 388 | 'cartItemList' => [ |
||
| 389 | [ |
||
| 390 | '@id' => '/v12/cart_items/1', |
||
| 391 | 'amount' => 1, |
||
| 392 | 'cartItemDetailList' => [ |
||
| 393 | [ |
||
| 394 | '@id' => '/v12/cart_item_detail/1', |
||
| 395 | 'name' => '', |
||
| 396 | ], |
||
| 397 | ], |
||
| 398 | ], |
||
| 399 | [ |
||
| 400 | '@id' => '/v12/cart_items/2', |
||
| 401 | 'amount' => 1, |
||
| 402 | ], |
||
| 403 | [ |
||
| 404 | '@id' => '/v12/cart_items/3', |
||
| 405 | 'amount' => 1, |
||
| 406 | 'cartItemDetailList' => [ |
||
| 407 | [ |
||
| 408 | '@id' => '/v12/cart_item_detail/2', |
||
| 409 | 'name' => '', |
||
| 410 | ], |
||
| 411 | ], |
||
| 412 | ], |
||
| 413 | ], |
||
| 414 | ], |
||
| 415 | [ |
||
| 416 | 'cartItemList' => [ |
||
| 417 | [ |
||
| 418 | '@id' => '/v12/cart_items/1', |
||
| 419 | 'amount' => 2, |
||
| 420 | 'cartItemDetailList' => [ |
||
| 421 | '@id' => '/v12/cart_item_detail/1', |
||
| 422 | 'name' => 'foo', |
||
| 423 | ], |
||
| 424 | ], |
||
| 425 | [ |
||
| 426 | '@id' => '/v12/cart_items/3', |
||
| 427 | 'amount' => 1, |
||
| 428 | ], |
||
| 429 | ], |
||
| 430 | ], |
||
| 431 | $this->getCartMetadata() |
||
| 432 | )) |
||
| 433 | ->isEqualTo( |
||
| 434 | [ |
||
| 435 | 'cartItemList' => [ |
||
| 436 | [ |
||
| 437 | 'amount' => 1, |
||
| 438 | 'cartItemDetailList' => [ |
||
| 439 | [ |
||
| 440 | '@id' => '/v12/cart_item_detail/1', |
||
| 441 | 'name' => '', |
||
| 442 | ], |
||
| 443 | ], |
||
| 444 | '@id' => '/v12/cart_items/1', |
||
| 445 | ], |
||
| 446 | [ |
||
| 447 | '@id' => '/v12/cart_items/2', |
||
| 448 | ], |
||
| 449 | [ |
||
| 450 | '@id' => '/v12/cart_items/3', |
||
| 451 | 'amount' => 1, |
||
| 452 | 'cartItemDetailList' => [ |
||
| 453 | [ |
||
| 454 | '@id' => '/v12/cart_item_detail/2', |
||
| 455 | 'name' => '', |
||
| 456 | ] |
||
| 457 | ], |
||
| 458 | ], |
||
| 459 | ] |
||
| 460 | ] |
||
| 461 | ) |
||
| 462 | ; |
||
| 463 | } |
||
| 464 | |||
| 538 |
This check marks private properties in classes that are never used. Those properties can be removed.