| Conditions | 10 |
| Paths | 256 |
| Total Lines | 34 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 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 |
||
| 12 | public function create($themeName, array $themeDefinition) |
||
| 13 | { |
||
| 14 | $theme = new Theme( |
||
| 15 | $themeName, |
||
| 16 | isset($themeDefinition['parent']) ? $themeDefinition['parent'] : null |
||
| 17 | ); |
||
| 18 | |||
| 19 | if (isset($themeDefinition['label'])) { |
||
| 20 | $theme->setLabel($themeDefinition['label']); |
||
| 21 | } |
||
| 22 | if (isset($themeDefinition['screenshot'])) { |
||
| 23 | $theme->setScreenshot($themeDefinition['screenshot']); |
||
| 24 | } |
||
| 25 | if (isset($themeDefinition['icon'])) { |
||
| 26 | $theme->setIcon($themeDefinition['icon']); |
||
| 27 | } |
||
| 28 | if (isset($themeDefinition['logo'])) { |
||
| 29 | $theme->setLogo($themeDefinition['logo']); |
||
| 30 | } |
||
| 31 | if (isset($themeDefinition['directory'])) { |
||
| 32 | $theme->setDirectory($themeDefinition['directory']); |
||
| 33 | } |
||
| 34 | if (isset($themeDefinition['groups'])) { |
||
| 35 | $theme->setGroups((array)$themeDefinition['groups']); |
||
| 36 | } |
||
| 37 | if (isset($themeDefinition['description'])) { |
||
| 38 | $theme->setDescription($themeDefinition['description']); |
||
| 39 | } |
||
| 40 | if (isset($themeDefinition['data'])) { |
||
| 41 | $theme->setData($themeDefinition['data']); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $theme; |
||
| 45 | } |
||
| 46 | } |
||
| 47 |