| Conditions | 11 |
| Paths | 10 |
| Total Lines | 24 |
| Code Lines | 15 |
| 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 |
||
| 64 | protected function buildValue() : string |
||
| 65 | { |
||
| 66 | $date = $this->oFG->getData()->getValue($this->strName); |
||
| 67 | |||
| 68 | $strValue = ''; |
||
| 69 | if (is_object($date) && get_class($date) == 'DateTime') { |
||
| 70 | // DateTime-object |
||
| 71 | $strValue = strftime($this->strDateFormat, $date->getTimestamp()); |
||
| 72 | } else if (is_numeric($date)) { |
||
| 73 | $strValue = strftime($this->strDateFormat, $date); |
||
| 74 | } else { |
||
| 75 | if ($date != '0000-00-00 00:00:00' && $date != '0000-00-00' && $date != '00:00:00') { |
||
| 76 | $unixtime = strtotime($date); |
||
| 77 | if ($unixtime !== false) { |
||
| 78 | $strValue = strftime($this->strDateFormat, $unixtime); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | $strHTML = ''; |
||
| 84 | if (!$this->oFlags->isSet(FormFlags::NO_ZERO) || ($strValue != 0 && $strValue != '0')) { |
||
| 85 | $strHTML = ' value="' . str_replace('"', '"', $strValue) . '"'; |
||
| 86 | } |
||
| 87 | return $strHTML; |
||
| 88 | } |
||
| 90 |