| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 35 |
| 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 declare(strict_types = 1); |
||
| 38 | public function serializationProvider(): array |
||
| 39 | { |
||
| 40 | return [ |
||
| 41 | [ |
||
| 42 | new Foo('5', new Bar(6, new Meh(1), new Meh(2), new Meh(3))), |
||
| 43 | json_encode([ |
||
| 44 | 'a' => '5', |
||
| 45 | 'bar' => [ |
||
| 46 | 'b' => 6, |
||
| 47 | 'meh' => ['c' => 1], |
||
| 48 | 'mehs' => [ |
||
| 49 | ['c' => 2], |
||
| 50 | ['c' => 3], |
||
| 51 | ] |
||
| 52 | ] |
||
| 53 | ]) |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | // Since this will not pass validation, were going to allow it |
||
| 57 | new Foo('5', new Bar(6, new Meh([1]), new Meh(2), new Meh(3))), |
||
| 58 | json_encode([ |
||
| 59 | 'a' => '5', |
||
| 60 | 'bar' => [ |
||
| 61 | 'b' => 6, |
||
| 62 | 'meh' => ['c' => [1]], |
||
| 63 | 'mehs' => [ |
||
| 64 | ['c' => 2], |
||
| 65 | ['c' => 3], |
||
| 66 | ] |
||
| 67 | ] |
||
| 68 | ]) |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | new Foo( |
||
| 72 | '5', |
||
| 73 | new Bar(6, new Meh([1]), new Meh(2), new Meh(3)), |
||
| 74 | new \DateTime('midnight'), |
||
| 75 | new \DateTime() |
||
| 76 | ), |
||
| 77 | json_encode([ |
||
| 78 | 'a' => '5', |
||
| 79 | 'bar' => [ |
||
| 80 | 'b' => 6, |
||
| 81 | 'meh' => ['c' => [1]], |
||
| 82 | 'mehs' => [ |
||
| 83 | ['c' => 2], |
||
| 84 | ['c' => 3], |
||
| 85 | ] |
||
| 86 | ], |
||
| 87 | 'aDate' => (new \DateTime('midnight'))->format('Y-m-d'), |
||
| 88 | 'aDateTime' => (new \DateTime())->format(\DateTime::ISO8601), |
||
| 89 | ]), |
||
| 90 | ], |
||
| 91 | ]; |
||
| 92 | } |
||
| 93 | } |
||
| 94 |