| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 15 | protected function getDataArray() |
||
| 16 | { |
||
| 17 | return [ |
||
| 18 | 'settings' => [ |
||
| 19 | 'setting' => [ |
||
| 20 | [ |
||
| 21 | '_id' => '1', |
||
| 22 | 'name' => 'foo', |
||
| 23 | 'profile' => [ |
||
| 24 | 'profile1', |
||
| 25 | ], |
||
| 26 | 'value' => '1', |
||
| 27 | 'type' => 'bool', |
||
| 28 | ], |
||
| 29 | [ |
||
| 30 | '_id' => '2', |
||
| 31 | 'name' => 'bar', |
||
| 32 | 'profile' => [ |
||
| 33 | 'profile1', |
||
| 34 | 'profile2', |
||
| 35 | ], |
||
| 36 | 'value' => 'test-string', |
||
| 37 | 'type' => 'string', |
||
| 38 | ], |
||
| 39 | [ |
||
| 40 | '_id' => '3', |
||
| 41 | 'name' => 'acme', |
||
| 42 | 'profile' => [ |
||
| 43 | 'profile2', |
||
| 44 | ], |
||
| 45 | 'value' => '0', |
||
| 46 | 'type' => 'bool', |
||
| 47 | ], |
||
| 48 | [ |
||
| 49 | '_id' => '4', |
||
| 50 | 'name' => 'active_profiles', |
||
| 51 | 'value' => [ |
||
| 52 | 'profile2', |
||
| 53 | ], |
||
| 54 | 'type' => 'hidden', |
||
| 55 | ], |
||
| 56 | [ |
||
| 57 | '_id' => '5', |
||
| 58 | 'name' => 'active_experiments', |
||
| 59 | 'value' => [ |
||
| 60 | 'foo_experiment', |
||
| 61 | ], |
||
| 62 | 'type' => 'hidden', |
||
| 63 | ], |
||
| 64 | [ |
||
| 65 | '_id' => '6', |
||
| 66 | 'name' => 'foo_experiment', |
||
| 67 | 'profile' => [ |
||
| 68 | 'profile1', |
||
| 69 | 'profile2', |
||
| 70 | ], |
||
| 71 | 'value' => [ |
||
| 72 | 'test_experiment_value', |
||
| 73 | ], |
||
| 74 | 'type' => 'experiment', |
||
| 75 | ], |
||
| 76 | [ |
||
| 77 | '_id' => '7', |
||
| 78 | 'name' => 'bar_experiment', |
||
| 79 | 'profile' => [ |
||
| 80 | 'profile1', |
||
| 81 | ], |
||
| 82 | 'value' => [ |
||
| 83 | 'test_experiment_value', |
||
| 84 | ], |
||
| 85 | 'type' => 'experiment', |
||
| 86 | ], |
||
| 87 | ] |
||
| 88 | ] |
||
| 89 | ]; |
||
| 90 | } |
||
| 91 | |||
| 196 |