| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 82 | public function customThemeDefinitionsAreRespectedProvider() |
||
| 83 | { |
||
| 84 | return [ |
||
| 85 | // Simple |
||
| 86 | [ |
||
| 87 | ['test' => $expected = [ |
||
| 88 | 'subsite', |
||
| 89 | 'backup', |
||
| 90 | '$public', |
||
| 91 | SSViewer::DEFAULT_THEME, |
||
| 92 | ]], |
||
| 93 | 'test', |
||
| 94 | $expected |
||
| 95 | ], |
||
| 96 | // Many options |
||
| 97 | [ |
||
| 98 | [ |
||
| 99 | 'aye' => [ |
||
| 100 | 'aye', |
||
| 101 | 'thing', |
||
| 102 | SSViewer::DEFAULT_THEME, |
||
| 103 | ], |
||
| 104 | 'bee' => $expected = [ |
||
| 105 | 'subsite', |
||
| 106 | 'backup', |
||
| 107 | '$public', |
||
| 108 | SSViewer::DEFAULT_THEME, |
||
| 109 | ], |
||
| 110 | 'sea' => [ |
||
| 111 | 'mer', |
||
| 112 | 'ocean', |
||
| 113 | SSViewer::DEFAULT_THEME, |
||
| 114 | ], |
||
| 115 | ], |
||
| 116 | 'bee', |
||
| 117 | $expected |
||
| 118 | ], |
||
| 119 | // Conflicting with root definitions |
||
| 120 | [ |
||
| 121 | ['main' => $expected = [ |
||
| 122 | 'subsite', |
||
| 123 | 'backup', |
||
| 124 | '$public', |
||
| 125 | SSViewer::DEFAULT_THEME, |
||
| 126 | ]], |
||
| 127 | 'main', |
||
| 128 | $expected |
||
| 129 | ], |
||
| 130 | // Declaring a theme specifically should still work |
||
| 131 | [ |
||
| 132 | ['test' => [ |
||
| 133 | 'subsite', |
||
| 134 | 'backup', |
||
| 135 | '$public', |
||
| 136 | SSViewer::DEFAULT_THEME, |
||
| 137 | ]], |
||
| 138 | 'other', |
||
| 139 | array_merge(['other'], $this->themeList) |
||
| 140 | ], |
||
| 144 |