Conditions | 1 |
Paths | 1 |
Total Lines | 94 |
Code Lines | 69 |
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 |
||
156 | protected function createDataProvider() |
||
157 | { |
||
158 | return [ |
||
159 | 'create transition' => [ |
||
160 | 'urlParams' => [ |
||
161 | 'workflow_id' => 1, |
||
162 | 'stage_id' => 1 |
||
163 | ], |
||
164 | 'data' => [ |
||
165 | 'source_stage_id' => 1, |
||
166 | 'target_stage_id' => 3, |
||
167 | 'name' => 'new Transition' |
||
168 | ], |
||
169 | 'httpCode' => HttpCode::CREATED, |
||
170 | ], |
||
171 | 'required data' => [ |
||
172 | 'urlParams' => [ |
||
173 | 'workflow_id' => 1, |
||
174 | 'stage_id' => 1 |
||
175 | ], |
||
176 | 'data' => [ |
||
177 | 'source_stage_id' => 2, |
||
178 | 'target_stage_id' => 3, |
||
179 | ], |
||
180 | 'httpCode' => HttpCode::UNPROCESSABLE_ENTITY, |
||
181 | 'validationErrors' => [ |
||
182 | 'name' => 'Transition Name cannot be blank.' |
||
183 | ], |
||
184 | ], |
||
185 | 'required data 2' => [ |
||
186 | 'urlParams' => [ |
||
187 | 'workflow_id' => 1, |
||
188 | 'stage_id' => 1 |
||
189 | ], |
||
190 | 'data' => [ |
||
191 | 'source_stage_id' => 1, |
||
192 | 'target_stage_id' => 4 |
||
193 | ], |
||
194 | 'httpCode' => HttpCode::UNPROCESSABLE_ENTITY, |
||
195 | 'validationErrors' => [ |
||
196 | 'name' => 'Transition Name cannot be blank.', |
||
197 | 'target_stage_id' => 'The stages are not associated to the same workflow.' |
||
198 | ], |
||
199 | ], |
||
200 | 'workflow not found' => [ |
||
201 | 'urlParams' => [ |
||
202 | 'workflow_id' => 10, |
||
203 | 'stage_id' => 1 |
||
204 | ], |
||
205 | 'data' => [ |
||
206 | 'source_stage_id' => 1, |
||
207 | 'target_stage_id' => 4 |
||
208 | ], |
||
209 | 'httpCode' => HttpCode::NOT_FOUND, |
||
210 | ], |
||
211 | 'stage not found' => [ |
||
212 | 'urlParams' => [ |
||
213 | 'workflow_id' => 1, |
||
214 | 'stage_id' => 19 |
||
215 | ], |
||
216 | 'data' => [ |
||
217 | 'source_stage_id' => 1, |
||
218 | 'target_stage_id' => 4 |
||
219 | ], |
||
220 | 'httpCode' => HttpCode::NOT_FOUND, |
||
221 | ], |
||
222 | 'unique source target' => [ |
||
223 | 'urlParams' => [ |
||
224 | 'workflow_id' => 1, |
||
225 | 'stage_id' => 1 |
||
226 | ], |
||
227 | 'data' => [ |
||
228 | 'source_stage_id' => 1, |
||
229 | 'target_stage_id' => 2, |
||
230 | 'name' => 'not unique' |
||
231 | ], |
||
232 | 'httpCode' => HttpCode::UNPROCESSABLE_ENTITY, |
||
233 | 'validationErrors' => [ |
||
234 | 'target_stage_id' => 'Target already in use for the source stage.' |
||
235 | ], |
||
236 | ], |
||
237 | 'unique source name' => [ |
||
238 | 'urlParams' => [ |
||
239 | 'workflow_id' => 1, |
||
240 | 'stage_id' => 1 |
||
241 | ], |
||
242 | 'data' => [ |
||
243 | 'source_stage_id' => 1, |
||
244 | 'target_stage_id' => 3, |
||
245 | 'name' => 'Transition 1 Stage 1 to Stage 2 Wf 1' |
||
246 | ], |
||
247 | 'httpCode' => HttpCode::UNPROCESSABLE_ENTITY, |
||
248 | 'validationErrors' => [ |
||
249 | 'name' => 'Name already used for the source stage.' |
||
250 | ], |
||
354 |