| Conditions | 2 |
| Paths | 2 |
| Total Lines | 71 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 43 | public function changeSchema(IOutput $output, |
||
| 44 | \Closure $schemaClosure, |
||
| 45 | array $options):?ISchemaWrapper { |
||
| 46 | /** @var ISchemaWrapper $schema */ |
||
| 47 | $schema = $schemaClosure(); |
||
| 48 | |||
| 49 | if (!$schema->hasTable('calendar_reminders')) { |
||
| 50 | $table = $schema->createTable('calendar_reminders'); |
||
| 51 | |||
| 52 | $table->addColumn('id', Type::BIGINT, [ |
||
| 53 | 'autoincrement' => true, |
||
| 54 | 'notnull' => true, |
||
| 55 | 'length' => 11, |
||
| 56 | 'unsigned' => true, |
||
| 57 | ]); |
||
| 58 | $table->addColumn('calendar_id', Type::BIGINT, [ |
||
| 59 | 'notnull' => true, |
||
| 60 | 'length' => 11, |
||
| 61 | ]); |
||
| 62 | $table->addColumn('object_id', Type::BIGINT, [ |
||
| 63 | 'notnull' => true, |
||
| 64 | 'length' => 11, |
||
| 65 | ]); |
||
| 66 | $table->addColumn('is_recurring', Type::SMALLINT, [ |
||
| 67 | 'notnull' => true, |
||
| 68 | 'length' => 1, |
||
| 69 | ]); |
||
| 70 | $table->addColumn('uid', Type::STRING, [ |
||
| 71 | 'notnull' => true, |
||
| 72 | 'length' => 255, |
||
| 73 | ]); |
||
| 74 | $table->addColumn('recurrence_id', Type::BIGINT, [ |
||
| 75 | 'notnull' => false, |
||
| 76 | 'length' => 11, |
||
| 77 | 'unsigned' => true, |
||
| 78 | ]); |
||
| 79 | $table->addColumn('is_recurrence_exception', Type::SMALLINT, [ |
||
| 80 | 'notnull' => true, |
||
| 81 | 'length' => 1, |
||
| 82 | ]); |
||
| 83 | $table->addColumn('event_hash', Type::STRING, [ |
||
| 84 | 'notnull' => true, |
||
| 85 | 'length' => 255, |
||
| 86 | ]); |
||
| 87 | $table->addColumn('alarm_hash', Type::STRING, [ |
||
| 88 | 'notnull' => true, |
||
| 89 | 'length' => 255, |
||
| 90 | ]); |
||
| 91 | $table->addColumn('type', Type::STRING, [ |
||
| 92 | 'notnull' => true, |
||
| 93 | 'length' => 255, |
||
| 94 | ]); |
||
| 95 | $table->addColumn('is_relative', Type::SMALLINT, [ |
||
| 96 | 'notnull' => true, |
||
| 97 | 'length' => 1, |
||
| 98 | ]); |
||
| 99 | $table->addColumn('notification_date', Type::BIGINT, [ |
||
| 100 | 'notnull' => true, |
||
| 101 | 'length' => 11, |
||
| 102 | 'unsigned' => true, |
||
| 103 | ]); |
||
| 104 | $table->addColumn('is_repeat_based', Type::SMALLINT, [ |
||
| 105 | 'notnull' => true, |
||
| 106 | 'length' => 1, |
||
| 107 | ]); |
||
| 108 | |||
| 109 | $table->setPrimaryKey(['id']); |
||
| 110 | $table->addIndex(['object_id'], 'calendar_reminder_objid'); |
||
| 111 | $table->addIndex(['uid', 'recurrence_id'], 'calendar_reminder_uidrec'); |
||
| 112 | |||
| 113 | return $schema; |
||
| 114 | } |
||
| 117 |