| Conditions | 3 |
| Paths | 4 |
| Total Lines | 66 |
| Code Lines | 46 |
| 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 |
||
| 9 | public function changeSchema(Schema $schema, array $options) { |
||
| 10 | $prefix = $options['tablePrefix']; |
||
| 11 | if (!$schema->hasTable("{$prefix}files_antivirus")) { |
||
| 12 | $table = $schema->createTable("{$prefix}files_antivirus"); |
||
| 13 | $table->addColumn('fileid', 'bigint', [ |
||
| 14 | 'unsigned' => true, |
||
| 15 | 'notnull' => true, |
||
| 16 | 'length' => 11, |
||
| 17 | ]); |
||
| 18 | |||
| 19 | $table->addColumn('check_time', 'integer', [ |
||
| 20 | 'notnull' => true, |
||
| 21 | 'unsigned' => true, |
||
| 22 | 'default' => 0, |
||
| 23 | ]); |
||
| 24 | $table->setPrimaryKey(['fileid']); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (!$schema->hasTable("{$prefix}files_avir_status")) { |
||
| 28 | $table = $schema->createTable("{$prefix}files_avir_status"); |
||
| 29 | $table->addColumn('id', 'integer', [ |
||
| 30 | 'autoincrement' => true, |
||
| 31 | 'unsigned' => true, |
||
| 32 | 'notnull' => true, |
||
| 33 | 'length' => 11, |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $table->addColumn('group_id', 'integer', [ |
||
| 37 | 'notnull' => true, |
||
| 38 | 'unsigned' => true, |
||
| 39 | 'default' => 0, |
||
| 40 | ]); |
||
| 41 | |||
| 42 | $table->addColumn('status_type', 'integer', [ |
||
| 43 | 'notnull' => true, |
||
| 44 | 'unsigned' => true, |
||
| 45 | 'default' => 0, |
||
| 46 | ]); |
||
| 47 | |||
| 48 | $table->addColumn('result', 'integer', [ |
||
| 49 | 'notnull' => true, |
||
| 50 | 'unsigned' => false, |
||
| 51 | 'default' => 0, |
||
| 52 | ]); |
||
| 53 | |||
| 54 | $table->addColumn('match', 'string', [ |
||
| 55 | 'length' => 64, |
||
| 56 | 'notnull' => false, |
||
| 57 | 'default' => null, |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $table->addColumn('description', 'string', [ |
||
| 61 | 'length' => 64, |
||
| 62 | 'notnull' => false, |
||
| 63 | 'default' => null, |
||
| 64 | ]); |
||
| 65 | |||
| 66 | $table->addColumn('status', 'integer', [ |
||
| 67 | 'length' => 4, |
||
| 68 | 'notnull' => true, |
||
| 69 | 'default' => 0, |
||
| 70 | 'unsigned' => false, |
||
| 71 | ]); |
||
| 72 | $table->setPrimaryKey(['id']); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 |