| Conditions | 16 |
| Paths | > 20000 |
| Total Lines | 66 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 272 |
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 |
||
| 50 | protected function createBuildTable() |
||
| 51 | { |
||
| 52 | $table = $this->table('build'); |
||
| 53 | |||
| 54 | if (!$this->hasTable('build')) { |
||
| 55 | $table->create(); |
||
| 56 | } |
||
| 57 | |||
| 58 | if (!$table->hasColumn('project_id')) { |
||
| 59 | $table->addColumn('project_id', 'integer'); |
||
| 60 | } |
||
| 61 | |||
| 62 | if (!$table->hasColumn('commit_id')) { |
||
| 63 | $table->addColumn('commit_id', 'string', array('limit' => 50)); |
||
| 64 | } |
||
| 65 | |||
| 66 | if (!$table->hasColumn('status')) { |
||
| 67 | $table->addColumn('status', 'integer', array('limit' => 4)); |
||
| 68 | } |
||
| 69 | |||
| 70 | if (!$table->hasColumn('log')) { |
||
| 71 | $table->addColumn('log', 'text'); |
||
| 72 | } |
||
| 73 | |||
| 74 | if (!$table->hasColumn('branch')) { |
||
| 75 | $table->addColumn('branch', 'string', array('limit' => 50)); |
||
| 76 | } |
||
| 77 | |||
| 78 | if (!$table->hasColumn('created')) { |
||
| 79 | $table->addColumn('created', 'datetime'); |
||
| 80 | } |
||
| 81 | |||
| 82 | if (!$table->hasColumn('started')) { |
||
| 83 | $table->addColumn('started', 'datetime'); |
||
| 84 | } |
||
| 85 | |||
| 86 | if (!$table->hasColumn('finished')) { |
||
| 87 | $table->addColumn('finished', 'datetime'); |
||
| 88 | } |
||
| 89 | |||
| 90 | if (!$table->hasColumn('committer_email')) { |
||
| 91 | $table->addColumn('committer_email', 'string', array('limit' => 250)); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (!$table->hasColumn('commit_message')) { |
||
| 95 | $table->addColumn('commit_message', 'text'); |
||
| 96 | } |
||
| 97 | |||
| 98 | if (!$table->hasColumn('extra')) { |
||
| 99 | $table->addColumn('extra', 'text'); |
||
| 100 | } |
||
| 101 | |||
| 102 | if ($table->hasColumn('plugins')) { |
||
| 103 | $table->removeColumn('plugins'); |
||
| 104 | } |
||
| 105 | |||
| 106 | if (!$table->hasIndex(array('project_id'))) { |
||
| 107 | $table->addIndex(array('project_id')); |
||
| 108 | } |
||
| 109 | |||
| 110 | if (!$table->hasIndex(array('status'))) { |
||
| 111 | $table->addIndex(array('status')); |
||
| 112 | } |
||
| 113 | |||
| 114 | $table->save(); |
||
| 115 | } |
||
| 116 | |||
| 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.