| Conditions | 4 |
| Paths | 8 |
| Total Lines | 82 |
| Code Lines | 59 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 22 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
||
| 23 | /** @var ISchemaWrapper $schema */ |
||
| 24 | $schema = $schemaClosure(); |
||
| 25 | |||
| 26 | if (!$schema->hasTable('flow_checks')) { |
||
| 27 | $table = $schema->createTable('flow_checks'); |
||
| 28 | $table->addColumn('id', Type::INTEGER, [ |
||
| 29 | 'autoincrement' => true, |
||
| 30 | 'notnull' => true, |
||
| 31 | 'length' => 4, |
||
| 32 | ]); |
||
| 33 | $table->addColumn('class', Type::STRING, [ |
||
| 34 | 'notnull' => true, |
||
| 35 | 'length' => 256, |
||
| 36 | ]); |
||
| 37 | $table->addColumn('operator', Type::STRING, [ |
||
| 38 | 'notnull' => true, |
||
| 39 | 'length' => 16, |
||
| 40 | ]); |
||
| 41 | $table->addColumn('value', Type::TEXT, [ |
||
| 42 | 'notnull' => false, |
||
| 43 | ]); |
||
| 44 | $table->addColumn('hash', Type::STRING, [ |
||
| 45 | 'notnull' => true, |
||
| 46 | 'length' => 32, |
||
| 47 | ]); |
||
| 48 | $table->setPrimaryKey(['id']); |
||
| 49 | $table->addUniqueIndex(['hash'], 'flow_unique_hash'); |
||
| 50 | } |
||
| 51 | |||
| 52 | if (!$schema->hasTable('flow_operations')) { |
||
| 53 | $table = $schema->createTable('flow_operations'); |
||
| 54 | $table->addColumn('id', Type::INTEGER, [ |
||
| 55 | 'autoincrement' => true, |
||
| 56 | 'notnull' => true, |
||
| 57 | 'length' => 4, |
||
| 58 | ]); |
||
| 59 | $table->addColumn('class', Type::STRING, [ |
||
| 60 | 'notnull' => true, |
||
| 61 | 'length' => 256, |
||
| 62 | ]); |
||
| 63 | $table->addColumn('name', Type::STRING, [ |
||
| 64 | 'notnull' => true, |
||
| 65 | 'length' => 256, |
||
| 66 | ]); |
||
| 67 | $table->addColumn('checks', Type::TEXT, [ |
||
| 68 | 'notnull' => false, |
||
| 69 | ]); |
||
| 70 | $table->addColumn('operation', Type::TEXT, [ |
||
| 71 | 'notnull' => false, |
||
| 72 | ]); |
||
| 73 | $this->ensureEntityColumns($table); |
||
| 74 | $table->setPrimaryKey(['id']); |
||
| 75 | } else { |
||
| 76 | $table = $schema->getTable('flow_operations'); |
||
| 77 | $this->ensureEntityColumns($table); |
||
| 78 | } |
||
| 79 | |||
| 80 | if (!$schema->hasTable('flow_operations_scope')) { |
||
| 81 | $table = $schema->createTable('flow_operations_scope'); |
||
| 82 | $table->addColumn('id', Type::BIGINT, [ |
||
| 83 | 'autoincrement' => true, |
||
| 84 | 'notnull' => true, |
||
| 85 | 'length' => 4, |
||
| 86 | ]); |
||
| 87 | $table->addColumn('operation_id', Type::INTEGER, [ |
||
| 88 | 'notnull' => true, |
||
| 89 | 'length' => 4, |
||
| 90 | ]); |
||
| 91 | $table->addColumn('type', Type::INTEGER, [ |
||
| 92 | 'notnull' => true, |
||
| 93 | 'length' => 4, |
||
| 94 | ]); |
||
| 95 | $table->addColumn('value', Type::STRING, [ |
||
| 96 | 'notnull' => false, |
||
| 97 | 'length' => 64, |
||
| 98 | ]); |
||
| 99 | $table->setPrimaryKey(['id']); |
||
| 100 | $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope'); |
||
| 101 | } |
||
| 102 | |||
| 103 | return $schema; |
||
| 104 | } |
||
| 121 |