Conditions | 3 |
Paths | 4 |
Total Lines | 102 |
Code Lines | 64 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
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 |
||
17 | public function changeSchema(Schema $schema, array $options) { |
||
18 | $prefix = $options['tablePrefix']; |
||
19 | if (!$schema->hasTable("{$prefix}files_antivirus")) { |
||
20 | $table = $schema->createTable("{$prefix}files_antivirus"); |
||
21 | $table->addColumn( |
||
22 | 'fileid', |
||
23 | 'bigint', |
||
24 | [ |
||
25 | 'unsigned' => true, |
||
26 | 'notnull' => true, |
||
27 | 'length' => 11, |
||
28 | ] |
||
29 | ); |
||
30 | |||
31 | $table->addColumn( |
||
32 | 'check_time', |
||
33 | 'integer', |
||
34 | [ |
||
35 | 'notnull' => true, |
||
36 | 'unsigned' => true, |
||
37 | 'default' => 0, |
||
38 | ] |
||
39 | ); |
||
40 | $table->setPrimaryKey(['fileid']); |
||
41 | } |
||
42 | |||
43 | if (!$schema->hasTable("{$prefix}files_avir_status")) { |
||
44 | $table = $schema->createTable("{$prefix}files_avir_status"); |
||
45 | $table->addColumn( |
||
46 | 'id', |
||
47 | 'integer', |
||
48 | [ |
||
49 | 'autoincrement' => true, |
||
50 | 'unsigned' => true, |
||
51 | 'notnull' => true, |
||
52 | 'length' => 11, |
||
53 | ] |
||
54 | ); |
||
55 | |||
56 | $table->addColumn( |
||
57 | 'group_id', |
||
58 | 'integer', |
||
59 | [ |
||
60 | 'notnull' => true, |
||
61 | 'unsigned' => true, |
||
62 | 'default' => 0, |
||
63 | ] |
||
64 | ); |
||
65 | |||
66 | $table->addColumn( |
||
67 | 'status_type', |
||
68 | 'integer', |
||
69 | [ |
||
70 | 'notnull' => true, |
||
71 | 'unsigned' => true, |
||
72 | 'default' => 0, |
||
73 | ] |
||
74 | ); |
||
75 | |||
76 | $table->addColumn( |
||
77 | 'result', |
||
78 | 'integer', |
||
79 | [ |
||
80 | 'notnull' => true, |
||
81 | 'unsigned' => false, |
||
82 | 'default' => 0, |
||
83 | ] |
||
84 | ); |
||
85 | |||
86 | $table->addColumn( |
||
87 | 'match', |
||
88 | 'string', |
||
89 | [ |
||
90 | 'length' => 64, |
||
91 | 'notnull' => false, |
||
92 | 'default' => null, |
||
93 | ] |
||
94 | ); |
||
95 | |||
96 | $table->addColumn( |
||
97 | 'description', |
||
98 | 'string', |
||
99 | [ |
||
100 | 'length' => 64, |
||
101 | 'notnull' => false, |
||
102 | 'default' => null, |
||
103 | ] |
||
104 | ); |
||
105 | |||
106 | $table->addColumn( |
||
107 | 'status', |
||
108 | 'integer', |
||
109 | [ |
||
110 | 'length' => 4, |
||
111 | 'notnull' => true, |
||
112 | 'default' => 0, |
||
113 | 'unsigned' => false, |
||
114 | ] |
||
115 | ); |
||
116 | $table->setPrimaryKey(['id']); |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 |