Conditions | 18 |
Paths | 1600 |
Total Lines | 60 |
Code Lines | 47 |
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 |
||
89 | public function getToolTip($langs, $soc, $type) |
||
90 | { |
||
91 | global $conf; |
||
92 | |||
93 | $langs->loadLangs(array("admin", "companies")); |
||
94 | |||
95 | $strikestart = ''; |
||
96 | $strikeend = ''; |
||
97 | if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) { |
||
98 | $strikestart = '<strike>'; |
||
99 | $strikeend = '</strike> ' . yn(1, 1, 2) . ' (' . $langs->trans("ForcedToByAModule", $langs->transnoentities("yes")) . ')'; |
||
100 | } |
||
101 | |||
102 | $s = ''; |
||
103 | if ($type == -1) { |
||
104 | $s .= $langs->trans("Name") . ': <b>' . $this->getName($langs) . '</b><br>'; |
||
105 | } elseif ($type == 0) { |
||
106 | $s .= $langs->trans("CustomerCodeDesc") . '<br>'; |
||
107 | } elseif ($type == 1) { |
||
108 | $s .= $langs->trans("SupplierCodeDesc") . '<br>'; |
||
109 | } |
||
110 | if ($type != -1) { |
||
111 | $s .= $langs->trans("ValidityControledByModule") . ': <b>' . $this->getName($langs) . '</b><br>'; |
||
112 | } |
||
113 | $s .= '<br>'; |
||
114 | $s .= '<u>' . $langs->trans("ThisIsModuleRules") . ':</u><br>'; |
||
115 | if ($type == 0) { |
||
116 | $s .= $langs->trans("RequiredIfCustomer") . ': ' . $strikestart; |
||
117 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
118 | $s .= '<br>'; |
||
119 | } elseif ($type == 1) { |
||
120 | $s .= $langs->trans("RequiredIfSupplier") . ': ' . $strikestart; |
||
121 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
122 | $s .= '<br>'; |
||
123 | } elseif ($type == -1) { |
||
124 | $s .= $langs->trans("Required") . ': ' . $strikestart; |
||
125 | $s .= yn(!$this->code_null, 1, 2) . $strikeend; |
||
126 | $s .= '<br>'; |
||
127 | } |
||
128 | $s .= $langs->trans("CanBeModifiedIfOk") . ': '; |
||
129 | $s .= yn($this->code_modifiable, 1, 2); |
||
130 | $s .= '<br>'; |
||
131 | $s .= $langs->trans("CanBeModifiedIfKo") . ': ' . yn($this->code_modifiable_invalide, 1, 2) . '<br>'; |
||
132 | $s .= $langs->trans("AutomaticCode") . ': ' . yn($this->code_auto, 1, 2) . '<br>'; |
||
133 | $s .= '<br>'; |
||
134 | if ($type == 0 || $type == -1) { |
||
135 | $nextval = $this->getNextValue($soc, 0); |
||
136 | if (empty($nextval)) { |
||
137 | $nextval = $langs->trans("Undefined"); |
||
138 | } |
||
139 | $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Customer") . ')' : '') . ': <b>' . $nextval . '</b><br>'; |
||
140 | } |
||
141 | if ($type == 1 || $type == -1) { |
||
142 | $nextval = $this->getNextValue($soc, 1); |
||
143 | if (empty($nextval)) { |
||
144 | $nextval = $langs->trans("Undefined"); |
||
145 | } |
||
146 | $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Supplier") . ')' : '') . ': <b>' . $nextval . '</b>'; |
||
147 | } |
||
148 | return $s; |
||
149 | } |
||
177 |