Conditions | 1 |
Paths | 1 |
Total Lines | 70 |
Code Lines | 45 |
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); |
||
51 | public function deserializationProvider(): array |
||
52 | { |
||
53 | return [ |
||
54 | [ |
||
55 | json_encode([ |
||
56 | 'a' => '5', |
||
57 | 'bar' => [ |
||
58 | 'b' => 6, |
||
59 | 'meh' => ['c' => 1], |
||
60 | 'mehs' => [ |
||
61 | ['c' => 2], |
||
62 | ['c' => 3], |
||
63 | ] |
||
64 | ] |
||
65 | ]), |
||
66 | new Foo('5', new Bar(6, new Meh(1), new Meh(2), new Meh(3))), |
||
67 | ], |
||
68 | [ |
||
69 | json_encode([ |
||
70 | 'a' => '5', |
||
71 | 'bar' => [ |
||
72 | 'b' => 6, |
||
73 | 'meh' => ['c' => [1]], |
||
74 | 'mehs' => [ |
||
75 | ['c' => 2], |
||
76 | ['c' => 3], |
||
77 | ] |
||
78 | ] |
||
79 | ]), |
||
80 | new Foo('5', new Bar(6, new Meh([1]), new Meh(2), new Meh(3))), |
||
81 | ], |
||
82 | // Will ignore non-existent properties, should be handled by validation |
||
83 | [ |
||
84 | json_encode([ |
||
85 | 'a' => '5', |
||
86 | 'b' => '5', |
||
87 | 'bar' => [ |
||
88 | 'b' => 6, |
||
89 | 'meh' => ['c' => [1]], |
||
90 | 'mehs' => [ |
||
91 | ['c' => 2], |
||
92 | ['c' => 3], |
||
93 | ] |
||
94 | ] |
||
95 | ]), |
||
96 | new Foo('5', new Bar(6, new Meh([1]), new Meh(2), new Meh(3))), |
||
97 | ], |
||
98 | [ |
||
99 | json_encode([ |
||
100 | 'a' => '5', |
||
101 | 'bar' => [ |
||
102 | 'b' => 6, |
||
103 | 'meh' => ['c' => [1]], |
||
104 | 'mehs' => [ |
||
105 | ['c' => 2], |
||
106 | ['c' => 3], |
||
107 | ] |
||
108 | ], |
||
109 | 'aDate' => (new \DateTime('midnight'))->format('Y-m-d'), |
||
110 | 'aDateTime' => (new \DateTime())->format(\DateTime::ISO8601), |
||
111 | ]), |
||
112 | new Foo( |
||
113 | '5', |
||
114 | new Bar(6, new Meh([1]), new Meh(2), new Meh(3)), |
||
115 | new \DateTime('midnight'), |
||
116 | new \DateTime() |
||
117 | ), |
||
118 | ], |
||
119 | ]; |
||
120 | } |
||
121 | } |
||
122 |