| Conditions | 10 |
| Paths | 28 |
| Total Lines | 54 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 10 |
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 | 3 | function setup( |
|
| 65 | $module, |
||
| 66 | $focus = null, |
||
| 67 | $metadataFile = null, |
||
| 68 | $tpl = 'include/DetailView/DetailView.tpl', |
||
| 69 | $createFocus = true |
||
| 70 | ) |
||
| 71 | { |
||
| 72 | 3 | global $sugar_config; |
|
| 73 | |||
| 74 | 3 | $this->th = new TemplateHandler(); |
|
| 75 | 3 | $this->th->ss = $this->ss; |
|
| 76 | |||
| 77 | //Check if inline editing is enabled for detail view. |
||
| 78 | 3 | if(!isset($sugar_config['enable_line_editing_detail']) || $sugar_config['enable_line_editing_detail']){ |
|
| 79 | 3 | $this->ss->assign('inline_edit', true); |
|
| 80 | } |
||
| 81 | 3 | $this->focus = $focus; |
|
| 82 | 3 | $this->tpl = $tpl; |
|
| 83 | 3 | $this->module = $module; |
|
| 84 | 3 | $this->metadataFile = $metadataFile; |
|
| 85 | 3 | if(isset($GLOBALS['sugar_config']['disable_vcr'])) { |
|
| 86 | $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr']; |
||
| 87 | } |
||
| 88 | 3 | if(!empty($this->metadataFile) && file_exists($this->metadataFile)){ |
|
| 89 | 2 | require($this->metadataFile); |
|
| 90 | }else { |
||
| 91 | //If file doesn't exist we create a best guess |
||
| 92 | 1 | if(!file_exists("modules/$this->module/metadata/detailviewdefs.php") && |
|
| 93 | 1 | file_exists("modules/$this->module/DetailView.html")) { |
|
| 94 | global $dictionary; |
||
| 95 | $htmlFile = "modules/" . $this->module . "/DetailView.html"; |
||
| 96 | $parser = new DetailViewMetaParser(); |
||
| 97 | if(!file_exists('modules/'.$this->module.'/metadata')) { |
||
| 98 | sugar_mkdir('modules/'.$this->module.'/metadata'); |
||
| 99 | } |
||
| 100 | $fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w'); |
||
| 101 | fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module)); |
||
| 102 | fclose($fp); |
||
| 103 | } |
||
| 104 | |||
| 105 | //Flag an error... we couldn't create the best guess meta-data file |
||
| 106 | 1 | if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) { |
|
| 107 | global $app_strings; |
||
| 108 | $error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']); |
||
| 109 | $GLOBALS['log']->fatal($error); |
||
| 110 | echo $error; |
||
| 111 | die(); |
||
| 112 | } |
||
| 113 | 1 | require("modules/$this->module/metadata/detailviewdefs.php"); |
|
| 114 | } |
||
| 115 | |||
| 116 | 3 | $this->defs = $viewdefs[$this->module][$this->view]; |
|
| 117 | 3 | } |
|
| 118 | |||
| 121 |
This class, trait or interface has been deprecated.