Conditions | 11 |
Paths | 432 |
Total Lines | 132 |
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 |
||
65 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
||
66 | /** @var ISchemaWrapper $schema */ |
||
67 | $schema = $schemaClosure(); |
||
68 | |||
69 | if ($schema->hasTable('circles_event')) { |
||
70 | $table = $schema->getTable('circles_event'); |
||
71 | if (!$table->hasColumn('updated')) { |
||
72 | $table->addColumn( |
||
73 | 'updated', 'datetime', [ |
||
74 | 'notnull' => false, |
||
75 | ] |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | if ($schema->hasTable('circles_member')) { |
||
81 | $table = $schema->getTable('circles_member'); |
||
82 | if (!$table->hasColumn('invited_by')) { |
||
83 | $table->addColumn( |
||
84 | 'invited_by', 'string', [ |
||
85 | 'notnull' => false, |
||
86 | 'default' => '', |
||
87 | 'length' => 31, |
||
88 | ] |
||
89 | ); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | if ($schema->hasTable('circles_circle')) { |
||
94 | $table = $schema->getTable('circles_circle'); |
||
95 | if (!$table->hasColumn('sanitized_name')) { |
||
96 | $table->addColumn( |
||
97 | 'sanitized_name', 'string', [ |
||
98 | 'notnull' => false, |
||
99 | 'default' => '', |
||
100 | 'length' => 127 |
||
101 | ] |
||
102 | ); |
||
103 | |||
104 | $table->addIndex(['sanitized_name']); |
||
105 | } |
||
106 | } |
||
107 | |||
108 | |||
109 | if ($schema->hasTable('circles_membership')) { |
||
110 | $table = $schema->getTable('circles_membership'); |
||
111 | $table->changeColumn( |
||
112 | 'circle_id', [ |
||
113 | 'notnull' => true, |
||
114 | 'length' => 31, |
||
115 | ] |
||
116 | ); |
||
117 | $table->changeColumn( |
||
118 | 'single_id', [ |
||
119 | 'notnull' => true, |
||
120 | 'length' => 31, |
||
121 | ] |
||
122 | ); |
||
123 | $table->changeColumn( |
||
124 | 'inheritance_first', [ |
||
125 | 'notnull' => true, |
||
126 | 'length' => 31, |
||
127 | ] |
||
128 | ); |
||
129 | $table->changeColumn( |
||
130 | 'inheritance_last', [ |
||
131 | 'notnull' => true, |
||
132 | 'length' => 31, |
||
133 | ] |
||
134 | ); |
||
135 | } |
||
136 | |||
137 | |||
138 | if ($schema->hasTable('circles_mount')) { |
||
139 | $table = $schema->getTable('circles_mount'); |
||
140 | $table->changeColumn( |
||
141 | 'mount_id', [ |
||
142 | 'notnull' => true, |
||
143 | 'length' => 31, |
||
144 | ] |
||
145 | ); |
||
146 | $table->changeColumn( |
||
147 | 'circle_id', [ |
||
148 | 'notnull' => true, |
||
149 | 'length' => 31, |
||
150 | ] |
||
151 | ); |
||
152 | $table->changeColumn( |
||
153 | 'single_id', [ |
||
154 | 'notnull' => true, |
||
155 | 'length' => 31, |
||
156 | ] |
||
157 | ); |
||
158 | } |
||
159 | |||
160 | |||
161 | if ($schema->hasTable('circles_mountpoint')) { |
||
162 | $table = $schema->getTable('circles_mountpoint'); |
||
163 | $table->changeColumn( |
||
164 | 'mount_id', [ |
||
165 | 'notnull' => true, |
||
166 | 'length' => 31, |
||
167 | ] |
||
168 | ); |
||
169 | $table->changeColumn( |
||
170 | 'single_id', [ |
||
171 | 'notnull' => true, |
||
172 | 'length' => 31, |
||
173 | ] |
||
174 | ); |
||
175 | } |
||
176 | |||
177 | |||
178 | if ($schema->hasTable('circles_share_lock')) { |
||
179 | $table = $schema->getTable('circles_share_lock'); |
||
180 | $table->changeColumn( |
||
181 | 'item_id', [ |
||
182 | 'notnull' => true, |
||
183 | 'length' => 31, |
||
184 | ] |
||
185 | ); |
||
186 | $table->changeColumn( |
||
187 | 'circle_id', [ |
||
188 | 'notnull' => true, |
||
189 | 'length' => 31, |
||
190 | ] |
||
191 | ); |
||
192 | } |
||
193 | |||
194 | |||
195 | return $schema; |
||
196 | } |
||
197 | |||
200 |