We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
Code Lines | 29 |
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 |
||
80 | public function testBackpackFormInputHandleDifferentInputTypesAtSameTime() |
||
81 | { |
||
82 | $input = [ |
||
83 | 'form' => [ |
||
84 | [ |
||
85 | 'name' => 'address[street]', |
||
86 | 'value' => 'street name', |
||
87 | ], |
||
88 | [ |
||
89 | 'name' => 'address[postal_code]', |
||
90 | 'value' => '234', |
||
91 | ], |
||
92 | [ |
||
93 | 'name' => 'repeatable[0][name]', |
||
94 | 'value' => 'first row name', |
||
95 | ], |
||
96 | [ |
||
97 | 'name' => 'repeatable[0][age]', |
||
98 | 'value' => '23', |
||
99 | ], |
||
100 | [ |
||
101 | 'name' => 'repeatable[1][name]', |
||
102 | 'value' => 'second row name', |
||
103 | ], |
||
104 | [ |
||
105 | 'name' => 'repeatable[1][age]', |
||
106 | 'value' => '24', |
||
107 | ], |
||
108 | [ |
||
109 | 'name' => 'simple_field', |
||
110 | 'value' => 'simple value', |
||
111 | ], |
||
112 | ], |
||
113 | ]; |
||
114 | |||
115 | $request = new Request($input); |
||
116 | app()->handle($request); |
||
117 | |||
118 | $expectedOutput = [ |
||
119 | 'address' => [ |
||
120 | 'street' => 'street name', |
||
121 | 'postal_code' => '234', |
||
122 | ], |
||
123 | 'repeatable' => [ |
||
124 | [ |
||
125 | 'name' => 'first row name', |
||
126 | 'age' => '23', |
||
127 | ], |
||
128 | [ |
||
129 | 'name' => 'second row name', |
||
130 | 'age' => '24', |
||
131 | ], |
||
132 | ], |
||
133 | 'simple_field' => 'simple value', |
||
134 | ]; |
||
135 | |||
136 | $this->assertEquals($expectedOutput, backpack_form_input()); |
||
137 | } |
||
139 |