| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 31 |
| 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 |
||
| 38 | public function testChainCommitWithRelation() |
||
| 39 | { |
||
| 40 | $entity = new TestReference(); |
||
| 41 | $parent = new TestEntity(); |
||
| 42 | $entity->setOwner($parent); |
||
| 43 | |||
| 44 | $this->getClient()->push( |
||
| 45 | $this->getResponseMock(true, 42), |
||
| 46 | function (RpcRequestInterface $request) { |
||
| 47 | self::assertEquals('test-entity/create', $request->getMethod()); |
||
| 48 | self::assertEquals( |
||
| 49 | [ |
||
| 50 | 'payload' => '', |
||
| 51 | 'parent' => null, |
||
| 52 | ], |
||
| 53 | $request->getParameters() |
||
| 54 | ); |
||
| 55 | |||
| 56 | return true; |
||
| 57 | } |
||
| 58 | ); |
||
| 59 | |||
| 60 | $this->getClient('test-reference-client')->push( |
||
| 61 | $this->getResponseMock(true, 241), |
||
| 62 | function (RpcRequestInterface $request) { |
||
| 63 | self::assertEquals('test-reference/create', $request->getMethod()); |
||
| 64 | self::assertEquals( |
||
| 65 | [ |
||
| 66 | 'reference-payload' => '', |
||
| 67 | 'owner' => 42, |
||
| 68 | ], |
||
| 69 | $request->getParameters() |
||
| 70 | ); |
||
| 71 | |||
| 72 | return true; |
||
| 73 | } |
||
| 74 | ); |
||
| 75 | |||
| 76 | $this->getManager()->persist($entity); |
||
| 77 | $this->getManager()->persist($parent); |
||
| 78 | $this->getManager()->flush(); |
||
| 79 | |||
| 80 | self::assertNotNull($parent->getId()); |
||
| 81 | self::assertEquals(42, $parent->getId()); |
||
| 82 | |||
| 83 | self::assertNotNull($entity->getId()); |
||
| 84 | self::assertEquals(241, $entity->getId()); |
||
| 85 | |||
| 86 | self::assertEquals($entity->getOwner(), $parent); |
||
| 87 | |||
| 88 | return $entity; |
||
| 89 | } |
||
| 90 | |||
| 167 |