| Conditions | 27 |
| Paths | 27 |
| Total Lines | 138 |
| Code Lines | 132 |
| 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 |
||
| 168 | public function getFieldInstanceByName($name) |
||
| 169 | { |
||
| 170 | $moduleName = $this->getName(true); |
||
| 171 | $params = ['uitype' => 7, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'I~M', 'presence' => 0, 'isEditableReadOnly' => false, 'maximumlength' => '', 'validator' => [['name' => 'NumberRange100']], 'source' => 'main']; |
||
| 172 | switch ($name) { |
||
| 173 | case 'MAX_NUMBER_EXPORT_RECORDS': |
||
| 174 | $params['label'] = $this->performanceFields[$name]; |
||
| 175 | $params['validator'] = [['name' => 'WholeNumberGreaterThanZero']]; |
||
| 176 | $params['uitype'] = 7; |
||
| 177 | $params['maximumlength'] = '99999999'; |
||
| 178 | $params['source'] = 'performance'; |
||
| 179 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 180 | $params['fieldvalue'] = $this->get($name); |
||
| 181 | break; |
||
| 182 | case 'listMaxEntriesMassEdit': |
||
| 183 | $params['maximumlength'] = '5000'; |
||
| 184 | $params['validator'] = [['name' => 'WholeNumberGreaterThanZero']]; |
||
| 185 | $params['label'] = $this->listFields[$name]; |
||
| 186 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 187 | break; |
||
| 188 | case 'upload_maxsize': |
||
| 189 | $params['label'] = $this->listFields[$name]; |
||
| 190 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 191 | $params['maximumlength'] = (string) round(\App\Config::getMaxUploadSize(false, true), 0) ?: ''; |
||
| 192 | unset($params['validator']); |
||
| 193 | break; |
||
| 194 | case 'layoutInLoginView': |
||
| 195 | case 'langInLoginView': |
||
| 196 | case 'backgroundClosingModal': |
||
| 197 | $params['label'] = $this->listFields[$name]; |
||
| 198 | $params['uitype'] = 56; |
||
| 199 | $params['typeofdata'] = 'C~M'; |
||
| 200 | $params['purifyType'] = \App\Purifier::BOOL; |
||
| 201 | unset($params['validator']); |
||
| 202 | break; |
||
| 203 | case 'breadcrumbs': |
||
| 204 | $params['label'] = $this->listFields[$name]; |
||
| 205 | $params['uitype'] = 56; |
||
| 206 | $params['typeofdata'] = 'C~M'; |
||
| 207 | $params['source'] = 'layout'; |
||
| 208 | $params['purifyType'] = \App\Purifier::BOOL; |
||
| 209 | unset($params['validator']); |
||
| 210 | break; |
||
| 211 | case 'default_module': |
||
| 212 | $params['label'] = $this->listFields[$name]; |
||
| 213 | $params['uitype'] = 16; |
||
| 214 | $params['maximumlength'] = '40'; |
||
| 215 | unset($params['validator']); |
||
| 216 | $params['picklistValues'] = ['Home' => \App\Language::translate('Home')]; |
||
| 217 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 218 | foreach (\vtlib\Functions::getAllModules(true, false, 0) as $module) { |
||
| 219 | $params['picklistValues'][$module['name']] = \App\Language::translate($module['name'], $module['name']); |
||
| 220 | } |
||
| 221 | break; |
||
| 222 | case 'defaultLayout': |
||
| 223 | $params['label'] = $this->listFields[$name]; |
||
| 224 | $params['uitype'] = 16; |
||
| 225 | $params['maximumlength'] = '50'; |
||
| 226 | $params['picklistValues'] = \App\Layout::getAllLayouts(); |
||
| 227 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 228 | unset($params['validator']); |
||
| 229 | break; |
||
| 230 | // Realtion |
||
| 231 | case 'COMMENT_MAX_LENGTH': |
||
| 232 | $params['label'] = $this->relationFields[$name]; |
||
| 233 | $params['uitype'] = 7; |
||
| 234 | $params['maximumlength'] = '200'; |
||
| 235 | $params['validator'] = [['name' => 'WholeNumberGreaterThanZero']]; |
||
| 236 | $params['source'] = 'relation'; |
||
| 237 | $params['tooltip'] = 'LBL_RELATION_COMMENT_MAX_LENGTH_DESC'; |
||
| 238 | $params['fieldvalue'] = $this->get($name); |
||
| 239 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 240 | break; |
||
| 241 | case 'SHOW_RELATED_MODULE_NAME': |
||
| 242 | case 'SHOW_RELATED_ICON': |
||
| 243 | case 'SHOW_RECORDS_COUNT': |
||
| 244 | $params['label'] = $this->relationFields[$name]; |
||
| 245 | $params['uitype'] = 56; |
||
| 246 | $params['typeofdata'] = 'C~M'; |
||
| 247 | $params['source'] = 'relation'; |
||
| 248 | $params['fieldvalue'] = $this->get($name); |
||
| 249 | $params['purifyType'] = \App\Purifier::BOOL; |
||
| 250 | unset($params['validator']); |
||
| 251 | break; |
||
| 252 | case 'separateChangeRelationButton': |
||
| 253 | $params['label'] = $this->relationFields[$name]; |
||
| 254 | $params['uitype'] = 56; |
||
| 255 | $params['typeofdata'] = 'C~M'; |
||
| 256 | $params['source'] = 'relation'; |
||
| 257 | $params['fieldvalue'] = $this->get($name); |
||
| 258 | $params['tooltip'] = 'LBL_RELATION_SEPARATE_CHANGE_RELATION_BUTTON_DESC'; |
||
| 259 | $params['purifyType'] = \App\Purifier::BOOL; |
||
| 260 | unset($params['validator']); |
||
| 261 | break; |
||
| 262 | case 'title_max_length': |
||
| 263 | case 'MINIMUM_CRON_FREQUENCY': |
||
| 264 | $params['uitype'] = 7; |
||
| 265 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 266 | $params['maximumlength'] = '0,100'; |
||
| 267 | break; |
||
| 268 | case 'listview_max_textlength': |
||
| 269 | case 'list_max_entries_per_page': |
||
| 270 | case 'href_max_length': |
||
| 271 | $params['uitype'] = 7; |
||
| 272 | $params['purifyType'] = \App\Purifier::INTEGER; |
||
| 273 | $params['maximumlength'] = '255'; |
||
| 274 | break; |
||
| 275 | // Branding |
||
| 276 | case 'footerName': |
||
| 277 | $params['label'] = $this->brandingFields[$name]; |
||
| 278 | $params['uitype'] = 1; |
||
| 279 | $params['typeofdata'] = 'V~O'; |
||
| 280 | $params['purifyType'] = \App\Purifier::TEXT; |
||
| 281 | $params['maximumlength'] = '255'; |
||
| 282 | $params['source'] = 'component:Branding'; |
||
| 283 | $params['fieldvalue'] = $this->get($name); |
||
| 284 | $params['isEditableReadOnly'] = !\App\YetiForce\Shop::check('YetiForceDisableBranding'); |
||
| 285 | unset($params['validator']); |
||
| 286 | break; |
||
| 287 | case 'urlFacebook': |
||
| 288 | case 'urlLinkedIn': |
||
| 289 | case 'urlTwitter': |
||
| 290 | $config = new \App\ConfigFile('component', 'Branding'); |
||
| 291 | $defaullt = $config->getTemplate($name)['default']; |
||
| 292 | $params['label'] = $this->brandingFields[$name]; |
||
| 293 | $params['uitype'] = 17; |
||
| 294 | $params['typeofdata'] = 'V~O'; |
||
| 295 | $params['purifyType'] = \App\Purifier::URL; |
||
| 296 | $params['maximumlength'] = '255'; |
||
| 297 | $params['source'] = 'component:Branding'; |
||
| 298 | $params['fieldvalue'] = $defaullt === $this->get($name) ? '' : $this->get($name); |
||
| 299 | $params['isEditableReadOnly'] = !\App\YetiForce\Shop::check('YetiForceDisableBranding'); |
||
| 300 | unset($params['validator']); |
||
| 301 | break; |
||
| 302 | default: |
||
| 303 | break; |
||
| 304 | } |
||
| 305 | return Settings_Vtiger_Field_Model::init($moduleName, $params); |
||
| 306 | } |
||
| 328 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths