| Conditions | 3 |
| Paths | 4 |
| Total Lines | 81 |
| 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 |
||
| 31 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
||
| 32 | /** @var ISchemaWrapper $schema */ |
||
| 33 | $schema = $schemaClosure(); |
||
| 34 | |||
| 35 | if (!$schema->hasTable('fulltextsearch_indexes')) { |
||
| 36 | $table = $schema->createTable('fulltextsearch_indexes'); |
||
| 37 | $table->addColumn('provider_id', 'string', [ |
||
| 38 | 'notnull' => true, |
||
| 39 | 'length' => 255, |
||
| 40 | ]); |
||
| 41 | $table->addColumn('document_id', 'string', [ |
||
| 42 | 'notnull' => true, |
||
| 43 | 'length' => 254, |
||
| 44 | ]); |
||
| 45 | $table->addColumn('source', 'string', [ |
||
| 46 | 'notnull' => false, |
||
| 47 | 'length' => 64, |
||
| 48 | ]); |
||
| 49 | $table->addColumn('owner_id', 'string', [ |
||
| 50 | 'notnull' => true, |
||
| 51 | 'length' => 64, |
||
| 52 | ]); |
||
| 53 | $table->addColumn('status', 'smallint', [ |
||
| 54 | 'notnull' => true, |
||
| 55 | 'length' => 1, |
||
| 56 | ]); |
||
| 57 | $table->addColumn('options', 'string', [ |
||
| 58 | 'notnull' => false, |
||
| 59 | 'length' => 511, |
||
| 60 | ]); |
||
| 61 | $table->addColumn('err', 'smallint', [ |
||
| 62 | 'notnull' => true, |
||
| 63 | 'length' => 1, |
||
| 64 | ]); |
||
| 65 | $table->addColumn('message', 'string', [ |
||
| 66 | 'notnull' => false, |
||
| 67 | 'length' => 8000, |
||
| 68 | ]); |
||
| 69 | $table->addColumn('indexed', 'bigint', [ |
||
| 70 | 'notnull' => false, |
||
| 71 | 'length' => 6, |
||
| 72 | ]); |
||
| 73 | $table->setPrimaryKey(['provider_id', 'document_id']); |
||
| 74 | } |
||
| 75 | |||
| 76 | if (!$schema->hasTable('fulltextsearch_ticks')) { |
||
| 77 | $table = $schema->createTable('fulltextsearch_ticks'); |
||
| 78 | $table->addColumn('id', 'bigint', [ |
||
| 79 | 'autoincrement' => true, |
||
| 80 | 'notnull' => true, |
||
| 81 | 'length' => 7, |
||
| 82 | 'unsigned' => true, |
||
| 83 | ]); |
||
| 84 | $table->addColumn('source', 'string', [ |
||
| 85 | 'notnull' => false, |
||
| 86 | 'length' => 128, |
||
| 87 | ]); |
||
| 88 | $table->addColumn('data', 'string', [ |
||
| 89 | 'notnull' => false, |
||
| 90 | 'length' => 6000, |
||
| 91 | ]); |
||
| 92 | $table->addColumn('status', 'string', [ |
||
| 93 | 'notnull' => false, |
||
| 94 | 'length' => 32, |
||
| 95 | ]); |
||
| 96 | $table->addColumn('action', 'string', [ |
||
| 97 | 'notnull' => false, |
||
| 98 | 'length' => 64, |
||
| 99 | ]); |
||
| 100 | $table->addColumn('first_tick', 'bigint', [ |
||
| 101 | 'notnull' => false, |
||
| 102 | 'length' => 6, |
||
| 103 | ]); |
||
| 104 | $table->addColumn('tick', 'bigint', [ |
||
| 105 | 'notnull' => false, |
||
| 106 | 'length' => 6, |
||
| 107 | ]); |
||
| 108 | $table->setPrimaryKey(['id']); |
||
| 109 | } |
||
| 110 | return $schema; |
||
| 111 | } |
||
| 112 | |||
| 121 |