| Conditions | 17 |
| Paths | 17 |
| Total Lines | 23 |
| Code Lines | 20 |
| 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 |
||
| 9 | private static function getCellFromPlaceholder($placeholder, SilverstripePage $sspage = null) |
||
| 10 | { |
||
| 11 | switch ($placeholder) { |
||
| 12 | case '%s': |
||
| 13 | return $sspage ? $sspage->getName() : "Site"; |
||
| 14 | case '%v': |
||
| 15 | return $sspage ? $sspage->getVersion() : "Version"; |
||
| 16 | case '%da': |
||
| 17 | return $sspage ? self::DefaultAdminText($sspage) : "DefaultAdmin"; |
||
| 18 | case '%el': |
||
| 19 | return $sspage ? self::EmailLoggingText($sspage) : "EmailLogging"; |
||
| 20 | case '%et': |
||
| 21 | return $sspage ? $sspage->getEnvironmentType() : "EnvironmentType"; |
||
| 22 | case '%m': |
||
| 23 | return $sspage ? self::ModuleText($sspage) : "Modules"; |
||
| 24 | case '%cfgp': |
||
| 25 | return $sspage ? $sspage->getConfigPhpPath() : "_config.php"; |
||
| 26 | case '%cfgy': |
||
| 27 | return $sspage ? $sspage->getConfigYmlPath() : "_config/config.yml"; |
||
| 28 | default: |
||
| 29 | return ""; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 67 |