| Conditions | 4 |
| Paths | 4 |
| Total Lines | 89 |
| Code Lines | 38 |
| 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 |
||
| 37 | function __construct($db) |
||
| 38 | { |
||
| 39 | global $langs, $conf, $mysoc; |
||
| 40 | |||
| 41 | $this->db = $db; |
||
| 42 | $this->numero = 3200; |
||
| 43 | // Key text used to identify module (for permissions, menus, etc...) |
||
| 44 | $this->rights_class = 'blockedlog'; |
||
| 45 | |||
| 46 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
||
| 47 | // It is used to group modules in module setup page |
||
| 48 | $this->family = "base"; |
||
| 49 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
| 50 | $this->name = preg_replace('/^mod/i','',get_class($this)); |
||
| 51 | $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; |
||
| 52 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
||
| 53 | $this->version = 'dolibarr'; |
||
| 54 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
||
| 55 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
||
| 56 | // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) |
||
| 57 | $this->special = 2; |
||
| 58 | // Name of image file used for this module. |
||
| 59 | $this->picto='technic'; |
||
| 60 | |||
| 61 | // Data directories to create when module is enabled |
||
| 62 | $this->dirs = array(); |
||
| 63 | |||
| 64 | // Config pages |
||
| 65 | //------------- |
||
| 66 | $this->config_page_url = array('blockedlog.php@blockedlog'); |
||
| 67 | |||
| 68 | // Dependancies |
||
| 69 | //------------- |
||
| 70 | $this->hidden = false; // A condition to disable module |
||
| 71 | $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled |
||
|
1 ignored issue
–
show
|
|||
| 72 | $this->requiredby = array(); // List of modules id to disable if this one is disabled |
||
| 73 | $this->conflictwith = array(); // List of modules id this module is in conflict with |
||
| 74 | $this->langfiles = array('blockedlog'); |
||
| 75 | |||
| 76 | $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
||
| 77 | $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
||
| 78 | $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation'); |
||
| 79 | |||
| 80 | // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must |
||
| 81 | // enable this module. |
||
| 82 | /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) |
||
| 83 | { |
||
| 84 | $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); |
||
| 85 | $this->automatic_activation = array(); |
||
| 86 | foreach($tmp as $key) |
||
| 87 | { |
||
| 88 | $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; |
||
| 89 | } |
||
| 90 | }*/ |
||
| 91 | //var_dump($this->automatic_activation); |
||
| 92 | |||
| 93 | $this->always_enabled = (!empty($conf->blockedlog->enabled) |
||
| 94 | && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) |
||
| 95 | && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) |
||
| 96 | && $this->alreadyUsed(1)); |
||
| 97 | |||
| 98 | // Constants |
||
| 99 | //----------- |
||
| 100 | $this->const = array( |
||
| 101 | 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) |
||
| 102 | ); |
||
| 103 | |||
| 104 | // New pages on tabs |
||
| 105 | // ----------------- |
||
| 106 | $this->tabs = array(); |
||
| 107 | |||
| 108 | // Boxes |
||
| 109 | //------ |
||
| 110 | $this->boxes = array(); |
||
| 111 | |||
| 112 | // Permissions |
||
| 113 | $this->rights = array(); // Permission array used by this module |
||
| 114 | |||
| 115 | $r=0; |
||
| 116 | $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) |
||
| 117 | $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label |
||
| 118 | $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
||
| 119 | $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) |
||
| 120 | $this->rights[$r][5] = ''; |
||
| 121 | |||
| 122 | // Main menu entries |
||
| 123 | //------------------ |
||
| 124 | $this->menu = array(); |
||
| 125 | } |
||
| 126 | |||
| 234 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..