| Conditions | 11 |
| Paths | 10 |
| Total Lines | 25 |
| Code Lines | 16 |
| 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 |
||
| 46 | protected function buildValue() : string |
||
| 47 | { |
||
| 48 | $date = $this->oFG->getData()->getValue($this->strName); |
||
| 49 | $strDateFormat = $this->oFG->getConfig()->getString('Date.Format', '%Y-%m-%d'); |
||
| 50 | |||
| 51 | $strValue = ''; |
||
| 52 | if (is_object($date) && get_class($date) == 'DateTime') { |
||
| 53 | // DateTime-object |
||
| 54 | $strValue = strftime($strDateFormat, $date->getTimestamp()); |
||
| 55 | } else if (is_numeric($date)) { |
||
| 56 | $strValue = strftime($strDateFormat, $date); |
||
| 57 | } else { |
||
| 58 | if ($date != '0000-00-00 00:00:00' && $date == '0000-00-00' && $date == '00:00:00') { |
||
| 59 | $unixtime = strtotime($date); |
||
| 60 | if ($unixtime !== false) { |
||
| 61 | $strValue = strftime($strDateFormat, $unixtime); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | $strHTML = ''; |
||
| 67 | if (!$this->oFlags->isSet(FormFlags::NO_ZERO) || ($strValue != 0 && $strValue != '0')) { |
||
| 68 | $strHTML = ' value="' . str_replace('"', '"', $strValue) . '"'; |
||
| 69 | } |
||
| 70 | return $strHTML; |
||
| 71 | } |
||
| 73 |