Conditions | 17 |
Paths | 6750 |
Total Lines | 86 |
Code Lines | 44 |
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 |
||
48 | public function up() { |
||
49 | |||
50 | $this->validate(); |
||
51 | |||
52 | if ($this->hasTable('access_collections')) { |
||
53 | $table = $this->table('access_collections'); |
||
54 | |||
55 | if ($table->hasIndex('site_guid')) { |
||
56 | $table->removeIndexByName('site_guid'); |
||
57 | } |
||
58 | |||
59 | if ($table->hasColumn('site_guid')) { |
||
60 | $table->removeColumn('site_guid'); |
||
61 | } |
||
62 | |||
63 | $table->save(); |
||
64 | } |
||
65 | |||
66 | if ($this->hasTable('api_users')) { |
||
67 | $table = $this->table('api_users'); |
||
68 | |||
69 | if ($table->hasColumn('site_guid')) { |
||
70 | $table->removeColumn('site_guid'); |
||
71 | } |
||
72 | |||
73 | $table->save(); |
||
74 | } |
||
75 | |||
76 | if ($this->hasTable('config')) { |
||
77 | $table = $this->table('config', [ |
||
78 | 'primary_key' => ["name"], |
||
79 | ]); |
||
80 | |||
81 | if ($table->hasIndex('site_guid')) { |
||
82 | $table->removeIndexByName('site_guid'); |
||
83 | } |
||
84 | |||
85 | if ($table->hasColumn('site_guid')) { |
||
86 | $table->removeColumn('site_guid'); |
||
87 | } |
||
88 | |||
89 | $table->save(); |
||
90 | } |
||
91 | |||
92 | if ($this->hasTable('entities')) { |
||
93 | $table = $this->table('entities'); |
||
94 | |||
95 | if ($table->hasIndex('site_guid')) { |
||
96 | $table->removeIndexByName('site_guid'); |
||
97 | } |
||
98 | |||
99 | if ($table->hasColumn('site_guid')) { |
||
100 | $table->removeColumn('site_guid'); |
||
101 | } |
||
102 | |||
103 | $table->save(); |
||
104 | } |
||
105 | |||
106 | if ($this->hasTable('users_apisessions')) { |
||
107 | $table = $this->table('users_apisessions'); |
||
108 | |||
109 | if ($table->hasIndex('site_guid')) { |
||
110 | $table->removeIndexByName('site_guid'); |
||
111 | } |
||
112 | |||
113 | if ($table->hasColumn('site_guid')) { |
||
114 | $table->removeColumn('site_guid'); |
||
115 | } |
||
116 | |||
117 | if ($table->hasIndex('user_guid')) { |
||
118 | $table->removeIndex('user_guid'); |
||
119 | } |
||
120 | |||
121 | $table->addIndex(['user_guid'], [ |
||
122 | 'name' => "user_guid", |
||
123 | 'unique' => false, |
||
124 | ]); |
||
125 | |||
126 | $table->save(); |
||
127 | } |
||
128 | |||
129 | if ($this->hasTable('entity_relationships')) { |
||
130 | // Remove member_of_site relaitonship following site_guid removal |
||
131 | $prefix = $this->getAdapter()->getOption('table_prefix'); |
||
132 | $this->query(" |
||
133 | DELETE FROM {$prefix}entity_relationships |
||
134 | WHERE relationship = 'member_of_site' |
||
317 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.