| Conditions | 13 |
| Paths | 4096 |
| Total Lines | 54 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 182 |
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 |
||
| 148 | protected function createProjectTable() |
||
| 149 | { |
||
| 150 | $table = $this->table('project'); |
||
| 151 | |||
| 152 | if (!$this->hasTable('project')) { |
||
| 153 | $table->create(); |
||
| 154 | } |
||
| 155 | |||
| 156 | if (!$table->hasColumn('title')) { |
||
| 157 | $table->addColumn('title', 'string', array('limit' => 250)); |
||
| 158 | } |
||
| 159 | |||
| 160 | if (!$table->hasColumn('reference')) { |
||
| 161 | $table->addColumn('reference', 'string', array('limit' => 250)); |
||
| 162 | } |
||
| 163 | |||
| 164 | if (!$table->hasColumn('git_key')) { |
||
| 165 | $table->addColumn('git_key', 'text'); |
||
| 166 | } |
||
| 167 | |||
| 168 | if (!$table->hasColumn('public_key')) { |
||
| 169 | $table->addColumn('public_key', 'text'); |
||
| 170 | } |
||
| 171 | |||
| 172 | if (!$table->hasColumn('type')) { |
||
| 173 | $table->addColumn('type', 'string', array('limit' => 50)); |
||
| 174 | } |
||
| 175 | |||
| 176 | if (!$table->hasColumn('access_information')) { |
||
| 177 | $table->addColumn('access_information', 'string', array('limit' => 250)); |
||
| 178 | } |
||
| 179 | |||
| 180 | if (!$table->hasColumn('last_commit')) { |
||
| 181 | $table->addColumn('last_commit', 'string', array('limit' => 250)); |
||
| 182 | } |
||
| 183 | |||
| 184 | if (!$table->hasColumn('build_config')) { |
||
| 185 | $table->addColumn('build_config', 'text'); |
||
| 186 | } |
||
| 187 | |||
| 188 | if (!$table->hasColumn('allow_public_status')) { |
||
| 189 | $table->addColumn('allow_public_status', 'integer'); |
||
| 190 | } |
||
| 191 | |||
| 192 | if ($table->hasColumn('token')) { |
||
| 193 | $table->removeColumn('token'); |
||
| 194 | } |
||
| 195 | |||
| 196 | if (!$table->hasIndex(array('title'))) { |
||
| 197 | $table->addIndex(array('title')); |
||
| 198 | } |
||
| 199 | |||
| 200 | $table->save(); |
||
| 201 | } |
||
| 202 | |||
| 234 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.