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