Conditions | 2 |
Paths | 2 |
Total Lines | 131 |
Code Lines | 82 |
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 |
||
28 | public function change() { |
||
29 | |||
30 | if ($this->hasTable("system_log")) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | $table = $this->table("system_log", [ |
||
35 | 'engine' => "InnoDB", |
||
36 | 'encoding' => "utf8mb4", |
||
37 | 'collation' => "utf8mb4_general_ci", |
||
38 | ]); |
||
39 | |||
40 | $table->addColumn('object_id', 'integer', [ |
||
41 | 'null' => false, |
||
42 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
43 | 'precision' => 10, |
||
44 | ]); |
||
45 | |||
46 | $table->addColumn('object_class', 'string', [ |
||
47 | 'null' => false, |
||
48 | 'limit' => 50, |
||
49 | ]); |
||
50 | |||
51 | $table->addColumn('object_type', 'string', [ |
||
52 | 'null' => false, |
||
53 | 'limit' => 50, |
||
54 | ]); |
||
55 | |||
56 | $table->addColumn('object_subtype', 'string', [ |
||
57 | 'null' => false, |
||
58 | 'limit' => 50, |
||
59 | ]); |
||
60 | |||
61 | $table->addColumn('event', 'string', [ |
||
62 | 'null' => false, |
||
63 | 'limit' => 50, |
||
64 | ]); |
||
65 | |||
66 | $table->addColumn('performed_by_guid', 'integer', [ |
||
67 | 'null' => false, |
||
68 | 'limit' => MysqlAdapter::INT_BIG, |
||
69 | 'precision' => 20, |
||
70 | 'signed' => false, |
||
71 | ]); |
||
72 | |||
73 | $table->addColumn('owner_guid', 'integer', [ |
||
74 | 'null' => false, |
||
75 | 'limit' => MysqlAdapter::INT_BIG, |
||
76 | 'precision' => 20, |
||
77 | 'signed' => false, |
||
78 | ]); |
||
79 | |||
80 | $table->addColumn('access_id', 'integer', [ |
||
81 | 'null' => false, |
||
82 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
83 | 'precision' => 10, |
||
84 | ]); |
||
85 | |||
86 | $table->addColumn('enabled', 'enum', [ |
||
87 | 'null' => false, |
||
88 | 'default' => 'yes', |
||
89 | 'limit' => 3, |
||
90 | 'values' => [ |
||
91 | 'yes', |
||
92 | 'no' |
||
93 | ], |
||
94 | ]); |
||
95 | |||
96 | $table->addColumn('time_created', 'integer', [ |
||
97 | 'null' => false, |
||
98 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
99 | 'precision' => 10, |
||
100 | ]); |
||
101 | |||
102 | $table->addColumn('ip_address', 'string', [ |
||
103 | 'null' => false, |
||
104 | 'limit' => 46, |
||
105 | ]); |
||
106 | |||
107 | $table->addIndex(['object_id'], [ |
||
108 | 'name' => "object_id", |
||
109 | 'unique' => false, |
||
110 | ]); |
||
111 | |||
112 | $table->addIndex(['object_class'], [ |
||
113 | 'name' => "object_class", |
||
114 | 'unique' => false, |
||
115 | ]); |
||
116 | |||
117 | $table->addIndex(['object_type'], [ |
||
118 | 'name' => "object_type", |
||
119 | 'unique' => false, |
||
120 | ]); |
||
121 | |||
122 | $table->addIndex(['object_subtype'], [ |
||
123 | 'name' => "object_subtype", |
||
124 | 'unique' => false, |
||
125 | ]); |
||
126 | |||
127 | $table->addIndex(['event'], [ |
||
128 | 'name' => "event", |
||
129 | 'unique' => false, |
||
130 | ]); |
||
131 | |||
132 | $table->addIndex(['performed_by_guid'], [ |
||
133 | 'name' => "performed_by_guid", |
||
134 | 'unique' => false, |
||
135 | ]); |
||
136 | |||
137 | $table->addIndex(['access_id'], [ |
||
138 | 'name' => "access_id", |
||
139 | 'unique' => false, |
||
140 | ]); |
||
141 | |||
142 | $table->addIndex(['time_created'], [ |
||
143 | 'name' => "time_created", |
||
144 | 'unique' => false, |
||
145 | ]); |
||
146 | |||
147 | $table->addIndex([ |
||
148 | 'object_type', |
||
149 | 'object_subtype', |
||
150 | 'event' |
||
151 | ], [ |
||
152 | 'name' => "river_key", |
||
153 | 'unique' => false |
||
154 | ]); |
||
155 | |||
156 | $table->save(); |
||
157 | |||
158 | } |
||
159 | } |
||
160 |