| Conditions | 18 |
| Paths | 1600 |
| Total Lines | 60 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 80 | public function getToolTip($langs, $product, $type) |
||
| 81 | { |
||
| 82 | global $conf; |
||
| 83 | |||
| 84 | $langs->loadLangs(array("admin", "companies")); |
||
| 85 | |||
| 86 | $strikestart = ''; |
||
| 87 | $strikeend = ''; |
||
| 88 | if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { |
||
| 89 | $strikestart = '<strike>'; |
||
| 90 | $strikeend = '</strike> ' . yn(1, 1, 2) . ' (' . $langs->trans("ForcedToByAModule", $langs->transnoentities("yes")) . ')'; |
||
| 91 | } |
||
| 92 | $s = ''; |
||
| 93 | if ($type == -1) { |
||
| 94 | $s .= $langs->trans("Name") . ': <b>' . $this->getName($langs) . '</b><br>'; |
||
| 95 | $s .= $langs->trans("Version") . ': <b>' . $this->getVersion() . '</b><br>'; |
||
| 96 | } elseif ($type == 0) { |
||
| 97 | $s .= $langs->trans("ProductCodeDesc") . '<br>'; |
||
| 98 | } elseif ($type == 1) { |
||
| 99 | $s .= $langs->trans("ServiceCodeDesc") . '<br>'; |
||
| 100 | } |
||
| 101 | if ($type != -1) { |
||
| 102 | $s .= $langs->trans("ValidityControledByModule") . ': <b>' . $this->getName($langs) . '</b><br>'; |
||
| 103 | } |
||
| 104 | $s .= '<br>'; |
||
| 105 | $s .= '<u>' . $langs->trans("ThisIsModuleRules") . ':</u><br>'; |
||
| 106 | if ($type == 0) { |
||
| 107 | $s .= $langs->trans("RequiredIfProduct") . ': ' . $strikestart; |
||
| 108 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
| 109 | $s .= '<br>'; |
||
| 110 | } elseif ($type == 1) { |
||
| 111 | $s .= $langs->trans("RequiredIfService") . ': ' . $strikestart; |
||
| 112 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
| 113 | $s .= '<br>'; |
||
| 114 | } elseif ($type == -1) { |
||
| 115 | $s .= $langs->trans("Required") . ': ' . $strikestart; |
||
| 116 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
| 117 | $s .= '<br>'; |
||
| 118 | } |
||
| 119 | $s .= $langs->trans("CanBeModifiedIfOk") . ': '; |
||
| 120 | $s .= yn($this->code_modifiable, 1, 2); |
||
| 121 | $s .= '<br>'; |
||
| 122 | $s .= $langs->trans("CanBeModifiedIfKo") . ': ' . yn($this->code_modifiable_invalide, 1, 2) . '<br>'; |
||
| 123 | $s .= $langs->trans("AutomaticCode") . ': ' . yn($this->code_auto, 1, 2) . '<br>'; |
||
| 124 | $s .= '<br>'; |
||
| 125 | if ($type == 0 || $type == -1) { |
||
| 126 | $nextval = $this->getNextValue($product, 0); |
||
| 127 | if (empty($nextval)) { |
||
| 128 | $nextval = $langs->trans("Undefined"); |
||
| 129 | } |
||
| 130 | $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Product") . ')' : '') . ': <b>' . $nextval . '</b><br>'; |
||
| 131 | } |
||
| 132 | if ($type == 1 || $type == -1) { |
||
| 133 | $nextval = $this->getNextValue($product, 1); |
||
| 134 | if (empty($nextval)) { |
||
| 135 | $nextval = $langs->trans("Undefined"); |
||
| 136 | } |
||
| 137 | $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Service") . ')' : '') . ': <b>' . $nextval . '</b>'; |
||
| 138 | } |
||
| 139 | return $s; |
||
| 140 | } |
||
| 168 |