| Conditions | 1 |
| Paths | 1 |
| Total Lines | 62 |
| Code Lines | 27 |
| 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 | function __construct($db) |
||
| 40 | { |
||
| 41 | $this->db = $db; |
||
| 42 | |||
| 43 | // Id for module (must be unique). |
||
| 44 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
||
| 45 | $this->numero = 50300; |
||
| 46 | // Key text used to identify module (for permissions, menus, etc...) |
||
| 47 | $this->rights_class = 'stripe'; |
||
| 48 | |||
| 49 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
||
| 50 | // It is used to group modules in module setup page |
||
| 51 | $this->family = "other"; |
||
| 52 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
| 53 | $this->name = preg_replace('/^mod/i','',get_class($this)); |
||
| 54 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
||
| 55 | $this->description = "Module to offer an online payment page by credit card with Stripe"; |
||
| 56 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
||
| 57 | $this->version = 'dolibarr'; |
||
| 58 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
||
| 59 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
||
| 60 | // Where to store the module in setup page (0=common,1=interface,2=other) |
||
| 61 | $this->special = 1; |
||
| 62 | // Name of image file used for this module. |
||
| 63 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
||
| 64 | // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' |
||
| 65 | $this->picto='stripe@stripe'; |
||
| 66 | |||
| 67 | // Data directories to create when module is enabled. |
||
| 68 | $this->dirs = array(); |
||
| 69 | |||
| 70 | // Config pages. Put here list of php page names stored in admmin directory used to setup module. |
||
| 71 | $this->config_page_url = array("stripe.php@stripe"); |
||
| 72 | |||
| 73 | // Dependencies |
||
| 74 | $this->depends = array(); // List of modules id that must be enabled if this module is enabled |
||
| 75 | $this->requiredby = array(); // List of modules id to disable if this one is disabled |
||
| 76 | $this->phpmin = array(5,3); // Minimum version of PHP required by module |
||
| 77 | $this->need_dolibarr_version = array(5,0); // Minimum version of Dolibarr required by module |
||
| 78 | $this->langfiles = array("stripe"); |
||
| 79 | |||
| 80 | // Constants |
||
| 81 | $this->const = array(); // List of particular constants to add when module is enabled |
||
| 82 | |||
| 83 | // New pages on tabs |
||
| 84 | $this->tabs = array(); |
||
| 85 | |||
| 86 | // Boxes |
||
| 87 | $this->boxes = array(); // List of boxes |
||
| 88 | $r=0; |
||
| 89 | |||
| 90 | // Permissions |
||
| 91 | $this->rights = array(); // Permission array used by this module |
||
| 92 | $r=0; |
||
| 93 | |||
| 94 | // Main menu entries |
||
| 95 | $this->menus = array(); // List of menus to add |
||
| 96 | $r=0; |
||
| 97 | |||
| 98 | // Exports |
||
| 99 | $r=1; |
||
| 100 | } |
||
| 101 | } |
||
| 103 |