| Conditions | 2 |
| Paths | 2 |
| Total Lines | 89 |
| Code Lines | 50 |
| 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 |
||
| 39 | public function __construct($db) |
||
| 40 | { |
||
| 41 | global $conf, $langs; |
||
| 42 | |||
| 43 | $this->db = $db; |
||
| 44 | $this->numero = 68000; |
||
| 45 | |||
| 46 | $this->family = "financial"; |
||
| 47 | $this->module_position = '100'; |
||
| 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
| 49 | $this->name = preg_replace('/^mod/i', '', get_class($this)); |
||
| 50 | $this->description = "Intracomm report management (Support for French DEB/DES format)"; |
||
| 51 | |||
| 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version |
||
| 53 | $this->version = 'development'; |
||
| 54 | |||
| 55 | $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); |
||
| 56 | $this->picto = 'intracommreport'; |
||
| 57 | |||
| 58 | // Data directories to create when module is enabled |
||
| 59 | $this->dirs = array('/intracommreport/temp'); |
||
| 60 | |||
| 61 | // Config pages |
||
| 62 | $this->config_page_url = array("intracommreport.php@intracommreport"); |
||
| 63 | |||
| 64 | // Dependencies |
||
| 65 | $this->depends = array("modFacture","modTax"); // List of modules id that must be enabled if this module is enabled |
||
| 66 | $this->requiredby = array(); // List of modules id to disable if this one is disabled |
||
| 67 | $this->conflictwith = array(); // List of modules id this module is in conflict with |
||
| 68 | $this->phpmin = array(5,5); // Minimum version of PHP required by module |
||
| 69 | $this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module |
||
| 70 | $this->langfiles = array("intracommreport"); |
||
| 71 | |||
| 72 | // Constants |
||
| 73 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
||
| 74 | // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), |
||
| 75 | // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) |
||
| 76 | // ); |
||
| 77 | $this->const = array(); |
||
| 78 | |||
| 79 | // Tabs |
||
| 80 | $this->tabs = array(); |
||
| 81 | |||
| 82 | // Css |
||
| 83 | $this->module_parts = array(); |
||
| 84 | |||
| 85 | // Boxes |
||
| 86 | $this->boxes = array(); |
||
| 87 | |||
| 88 | // Dictionaries |
||
| 89 | if (! isset($conf->intracommreport->enabled)) |
||
| 90 | { |
||
| 91 | $conf->intracommreport=new stdClass(); |
||
| 92 | $conf->intracommreport->enabled=0; |
||
| 93 | } |
||
| 94 | $this->dictionaries=array(); |
||
| 95 | |||
| 96 | // Permissions |
||
| 97 | $this->rights = array(); |
||
| 98 | $this->rights_class = 'intracommreport'; |
||
| 99 | $r = 0; |
||
| 100 | |||
| 101 | $r++; |
||
| 102 | $this->rights[$r][0] = 68001; |
||
| 103 | $this->rights[$r][1] = 'Read intracomm report'; |
||
| 104 | $this->rights[$r][2] = 'r'; |
||
| 105 | $this->rights[$r][3] = 0; |
||
| 106 | $this->rights[$r][4] = 'read'; |
||
| 107 | |||
| 108 | $r++; |
||
| 109 | $this->rights[$r][0] = 68002; |
||
| 110 | $this->rights[$r][1] = 'Create/modify intracomm report'; |
||
| 111 | $this->rights[$r][2] = 'w'; |
||
| 112 | $this->rights[$r][3] = 0; |
||
| 113 | $this->rights[$r][4] = 'write'; |
||
| 114 | |||
| 115 | $r++; |
||
| 116 | $this->rights[$r][0] = 68004; |
||
| 117 | $this->rights[$r][1] = 'Delete intracomm report'; |
||
| 118 | $this->rights[$r][2] = 'd'; |
||
| 119 | $this->rights[$r][3] = 0; |
||
| 120 | $this->rights[$r][4] = 'delete'; |
||
| 121 | |||
| 122 | // Main menu entries |
||
| 123 | $this->menu = array(); // List of menus to add |
||
| 124 | $r=0; |
||
| 125 | |||
| 126 | // Exports |
||
| 127 | $r=1; |
||
| 128 | } |
||
| 130 |