| Conditions | 11 |
| Paths | 27 |
| Total Lines | 40 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 21 | public function renderInternal() |
||
| 22 | { |
||
| 23 | $lines = array(); |
||
| 24 | $lines[] = 'Test'; |
||
| 25 | $myName = false; |
||
| 26 | $listType = $this->contentObject->data['list_type']; |
||
| 27 | $template = $GLOBALS['TSFE']->tmpl; |
||
| 28 | |||
| 29 | if (isset($template->setup['tt_content.']['list.']['20.'][$listType])) { |
||
| 30 | $theValue = $template->setup['tt_content.']['list.']['20.'][$listType]; |
||
| 31 | $theConf = $template->setup['tt_content.']['list.']['20.'][$listType . '.']; |
||
| 32 | } else { |
||
| 33 | $tmp = explode('_pi', $listType); |
||
| 34 | if (count($tmp) < 2) { |
||
| 35 | $myName = 'tx_' . str_replace('_', '', $tmp[0]); |
||
| 36 | } else { |
||
| 37 | $myName = 'tx_' . str_replace('_', '', $tmp[0]) . '_pi' . $tmp[1]; |
||
| 38 | } |
||
| 39 | $theValue = $template->setup['plugin.'][$myName]; |
||
| 40 | $theConf = $template->setup['plugin.'][$myName . '.']; |
||
| 41 | } |
||
| 42 | $content = $this->contentObject->cObjGetSingle($theValue, $theConf); |
||
| 43 | |||
| 44 | $myContent = $this->breakContent(strip_tags($content)); |
||
| 45 | if (strlen($myContent) > 1) { |
||
| 46 | if (substr($myContent, 0, 1) == '|' && substr($myContent, -1) == '|') { |
||
| 47 | $myContent = substr($myContent, 1, strlen($myContent) - 2); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | if (!is_array($theConf) || strlen($theConf['plainType']) < 2) { |
||
| 52 | $defaultOutput = $this->configuration['defaultOutput']; |
||
| 53 | if ($defaultOutput && $myName) { |
||
|
|
|||
| 54 | $lines[] = str_replace('###CType###', $this->contentObject->data['CType'] . ': "' . $this->contentObject->data['list_type'] . '"; plugin: "' . $myName . '"; plainType: "' . (is_array($theConf) ? $theConf['plainType'] : '') . '"', $defaultOutput); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | $lines[] = $myContent; |
||
| 59 | return $lines; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: