Conditions | 2 |
Paths | 2 |
Total Lines | 69 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 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 |
||
97 | public function _install() { |
||
98 | |||
99 | $email_patterns = $this->found_less_expensive_model->getEmailPatterns(); |
||
100 | $this->db->insert('mod_email_paterns', $email_patterns); |
||
101 | |||
102 | $email_patterns_i18n = $this->found_less_expensive_model->getEmailPatternsI18n(); |
||
103 | $this->db->insert('mod_email_paterns_i18n', $email_patterns_i18n); |
||
104 | |||
105 | $this->load->dbforge(); |
||
106 | ($this->dx_auth->is_admin()) OR exit; |
||
107 | $fields = [ |
||
108 | 'id' => [ |
||
109 | 'type' => 'INT', |
||
110 | 'auto_increment' => TRUE, |
||
111 | ], |
||
112 | 'name' => [ |
||
113 | 'type' => 'VARCHAR', |
||
114 | 'constraint' => '70', |
||
115 | 'null' => TRUE, |
||
116 | ], |
||
117 | 'email' => [ |
||
118 | 'type' => 'VARCHAR', |
||
119 | 'constraint' => '50', |
||
120 | 'null' => TRUE, |
||
121 | ], |
||
122 | 'phone' => [ |
||
123 | 'type' => 'VARCHAR', |
||
124 | 'constraint' => '50', |
||
125 | 'null' => TRUE, |
||
126 | ], |
||
127 | 'question' => [ |
||
128 | 'type' => 'VARCHAR', |
||
129 | 'constraint' => '250', |
||
130 | 'null' => TRUE, |
||
131 | ], |
||
132 | 'link' => [ |
||
133 | 'type' => 'VARCHAR', |
||
134 | 'constraint' => '150', |
||
135 | 'null' => TRUE, |
||
136 | ], |
||
137 | 'productUrl' => [ |
||
138 | 'type' => 'VARCHAR', |
||
139 | 'constraint' => '250', |
||
140 | 'null' => TRUE, |
||
141 | ], |
||
142 | 'date' => [ |
||
143 | 'type' => 'INT', |
||
144 | 'null' => TRUE, |
||
145 | ], |
||
146 | 'status' => [ |
||
147 | 'type' => 'VARCHAR', |
||
148 | 'constraint' => '150', |
||
149 | 'null' => TRUE, |
||
150 | ], |
||
151 | ]; |
||
152 | |||
153 | $this->dbforge->add_field($fields); |
||
154 | $this->dbforge->add_key('id', TRUE); |
||
155 | $this->dbforge->create_table('mod_found_less_expensive'); |
||
156 | |||
157 | $this->db->where('name', 'found_less_expensive'); |
||
158 | $this->db->update( |
||
159 | 'components', |
||
160 | [ |
||
161 | 'enabled' => 1, |
||
162 | 'autoload' => 1, |
||
163 | ] |
||
164 | ); |
||
165 | } |
||
166 | |||
176 | } |