Conditions | 2 |
Paths | 2 |
Total Lines | 85 |
Code Lines | 58 |
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}share_external")) { |
||
12 | $table = $schema->createTable("{$prefix}share_external"); |
||
13 | $table->addColumn('id', 'bigint', [ |
||
14 | 'autoincrement' => true, |
||
15 | 'unsigned' => false, |
||
16 | 'notnull' => true, |
||
17 | 'length' => 11, |
||
18 | ]); |
||
19 | |||
20 | $table->addColumn('remote', 'string', [ |
||
21 | 'notnull' => true, |
||
22 | 'length' => 512, |
||
23 | 'default' => null, |
||
24 | 'comment' => 'Url of the remote owncloud instance' |
||
25 | ]); |
||
26 | |||
27 | $table->addColumn('remote_id', 'bigint', [ |
||
28 | 'unsigned' => false, |
||
29 | 'notnull' => true, |
||
30 | 'default' => -1, |
||
31 | 'length' => 11, |
||
32 | ]); |
||
33 | |||
34 | $table->addColumn('share_token', 'string', [ |
||
35 | 'length' => 64, |
||
36 | 'notnull' => true, |
||
37 | 'comment' => 'Public share token' |
||
38 | ]); |
||
39 | |||
40 | $table->addColumn('password', 'string', [ |
||
41 | 'length' => 64, |
||
42 | 'notnull' => false, |
||
43 | 'default' => null, |
||
44 | 'comment' => 'Optional password for the public share' |
||
45 | ]); |
||
46 | |||
47 | $table->addColumn('name', 'string', [ |
||
48 | 'length' => 64, |
||
49 | 'notnull' => true, |
||
50 | 'comment' => 'Original name on the remote server' |
||
51 | ]); |
||
52 | |||
53 | $table->addColumn('owner', 'string', [ |
||
54 | 'length' => 64, |
||
55 | 'notnull' => true, |
||
56 | 'comment' => 'User that owns the public share on the remote server' |
||
57 | ]); |
||
58 | |||
59 | $table->addColumn('user', 'string', [ |
||
60 | 'length' => 64, |
||
61 | 'notnull' => true, |
||
62 | 'comment' => 'Local user which added the external share' |
||
63 | ]); |
||
64 | |||
65 | $table->addColumn('mountpoint', 'string', [ |
||
66 | 'length' => 4000, |
||
67 | 'notnull' => true, |
||
68 | 'comment' => 'Full path where the share is mounted' |
||
69 | ]); |
||
70 | |||
71 | $table->addColumn('mountpoint_hash', 'string', [ |
||
72 | 'length' => 32, |
||
73 | 'notnull' => true, |
||
74 | 'comment' => 'md5 hash of the mountpoint' |
||
75 | ]); |
||
76 | |||
77 | $table->addColumn('accepted', 'integer', [ |
||
78 | 'notnull' => true, |
||
79 | 'default' => 0, |
||
80 | ]); |
||
81 | |||
82 | $table->setPrimaryKey(['id']); |
||
83 | |||
84 | $table->addIndex( |
||
85 | ['user'], |
||
86 | 'sh_external_user' |
||
87 | ); |
||
88 | $table->addUniqueIndex( |
||
89 | ['user', 'mountpoint_hash'], |
||
90 | 'sh_external_mp' |
||
91 | ); |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 |