Conditions | 10 |
Paths | 162 |
Total Lines | 64 |
Code Lines | 39 |
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 |
||
40 | public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
||
41 | /** @var ISchemaWrapper $schema */ |
||
42 | $schema = $schemaClosure(); |
||
43 | |||
44 | if ($schema->hasTable('calendarchanges')) { |
||
45 | $calendarChangesTable = $schema->getTable('calendarchanges'); |
||
46 | $calendarChangesTable->addColumn('calendartype', Type::INTEGER, [ |
||
47 | 'notnull' => true, |
||
48 | 'default' => 0, |
||
49 | ]); |
||
50 | |||
51 | if ($calendarChangesTable->hasIndex('calendarid_synctoken')) { |
||
52 | $calendarChangesTable->dropIndex('calendarid_synctoken'); |
||
53 | } |
||
54 | $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calendarid_calendartype_synctoken'); |
||
55 | } |
||
56 | |||
57 | if ($schema->hasTable('calendarobjects')) { |
||
58 | $calendarObjectsTable = $schema->getTable('calendarobjects'); |
||
59 | $calendarObjectsTable->addColumn('calendartype', Type::INTEGER, [ |
||
60 | 'notnull' => true, |
||
61 | 'default' => 0, |
||
62 | ]); |
||
63 | |||
64 | if ($calendarObjectsTable->hasIndex('calobjects_index')) { |
||
65 | $calendarObjectsTable->dropIndex('calobjects_index'); |
||
66 | } |
||
67 | $calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index'); |
||
68 | } |
||
69 | |||
70 | if ($schema->hasTable('calendarobjects_props')) { |
||
71 | $calendarObjectsPropsTable = $schema->getTable('calendarobjects_props'); |
||
72 | $calendarObjectsPropsTable->addColumn('calendartype', Type::INTEGER, [ |
||
73 | 'notnull' => true, |
||
74 | 'default' => 0, |
||
75 | ]); |
||
76 | |||
77 | |||
78 | if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) { |
||
79 | $calendarObjectsPropsTable->dropIndex('calendarobject_index'); |
||
80 | } |
||
81 | if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) { |
||
82 | $calendarObjectsPropsTable->dropIndex('calendarobject_name_index'); |
||
83 | } |
||
84 | if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) { |
||
85 | $calendarObjectsPropsTable->dropIndex('calendarobject_value_index'); |
||
86 | } |
||
87 | |||
88 | $calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index'); |
||
89 | $calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index'); |
||
90 | $calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index'); |
||
91 | } |
||
92 | |||
93 | if ($schema->hasTable('calendarsubscriptions')) { |
||
94 | $calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions'); |
||
95 | $calendarSubscriptionsTable->addColumn('synctoken', 'integer', [ |
||
96 | 'notnull' => true, |
||
97 | 'default' => 1, |
||
98 | 'length' => 10, |
||
99 | 'unsigned' => true, |
||
100 | ]); |
||
101 | } |
||
102 | |||
103 | return $schema; |
||
104 | } |
||
106 |