Conditions | 2 |
Paths | 2 |
Total Lines | 62 |
Code Lines | 43 |
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 |
||
9 | public function changeSchema(Schema $schema, array $options) { |
||
10 | $prefix = $options['tablePrefix']; |
||
11 | if (!$schema->hasTable("{$prefix}files_trash")) { |
||
12 | $table = $schema->createTable("{$prefix}files_trash"); |
||
13 | $table->addColumn('auto_id', 'bigint', [ |
||
14 | 'autoincrement' => true, |
||
15 | 'unsigned' => false, |
||
16 | 'notnull' => true, |
||
17 | 'length' => 11, |
||
18 | ]); |
||
19 | |||
20 | $table->addColumn('id', 'string', [ |
||
21 | 'length' => 250, |
||
22 | 'notnull' => true, |
||
23 | 'default' => '' |
||
24 | ]); |
||
25 | |||
26 | $table->addColumn('user', 'string', [ |
||
27 | 'length' => 64, |
||
28 | 'notnull' => true, |
||
29 | 'default' => '' |
||
30 | ]); |
||
31 | |||
32 | $table->addColumn('timestamp', 'string', [ |
||
33 | 'length' => 12, |
||
34 | 'notnull' => true, |
||
35 | 'default' => '' |
||
36 | ]); |
||
37 | |||
38 | $table->addColumn('location', 'string', [ |
||
39 | 'length' => 512, |
||
40 | 'notnull' => true, |
||
41 | 'default' => '' |
||
42 | ]); |
||
43 | |||
44 | $table->addColumn('type', 'string', [ |
||
45 | 'length' => 4, |
||
46 | 'notnull' => false, |
||
47 | 'default' => null |
||
48 | ]); |
||
49 | |||
50 | $table->addColumn('mime', 'string', [ |
||
51 | 'length' => 255, |
||
52 | 'notnull' => false, |
||
53 | 'default' => null |
||
54 | ]); |
||
55 | |||
56 | $table->setPrimaryKey(['auto_id']); |
||
57 | $table->addIndex( |
||
58 | ['id'], |
||
59 | 'id_index' |
||
60 | ); |
||
61 | $table->addIndex( |
||
62 | ['timestamp'], |
||
63 | 'timestamp_index' |
||
64 | ); |
||
65 | $table->addIndex( |
||
66 | ['user'], |
||
67 | 'user_index' |
||
68 | ); |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 |