| Conditions | 17 |
| Paths | 6561 |
| Total Lines | 48 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 105 | public function updateTable(DbupdaterTable $table) |
||
| 106 | { |
||
| 107 | $ret = true; |
||
| 108 | echo '<ul>'; |
||
| 109 | |||
| 110 | // If table has a structure, create the table |
||
| 111 | if ($table->getStructure()) { |
||
| 112 | $ret = $table->createTable() && $ret; |
||
| 113 | } |
||
| 114 | |||
| 115 | // If table is flag for drop, drop it |
||
| 116 | if ($table->_flagForDrop) { |
||
|
|
|||
| 117 | $ret = $table->dropTable() && $ret; |
||
| 118 | } |
||
| 119 | |||
| 120 | // If table has data, insert it |
||
| 121 | if ($table->getData()) { |
||
| 122 | $ret = $table->addData() && $ret; |
||
| 123 | } |
||
| 124 | |||
| 125 | // If table has new fields to be added, add them |
||
| 126 | if ($table->getNewFields()) { |
||
| 127 | $ret = $table->addNewFields() && $ret; |
||
| 128 | } |
||
| 129 | |||
| 130 | // If table has altered field, alter the table |
||
| 131 | if ($table->getAlteredFields()) { |
||
| 132 | $ret = $table->alterTable() && $ret; |
||
| 133 | } |
||
| 134 | |||
| 135 | // If table has updated field values, update the table |
||
| 136 | if ($table->getUpdatedFields()) { |
||
| 137 | $ret = $table->updateFieldsValues($table) && $ret; |
||
| 138 | } |
||
| 139 | |||
| 140 | // If table has droped field, alter the table |
||
| 141 | if ($table->getDropedFields()) { |
||
| 142 | $ret = $table->dropFields($table) && $ret; |
||
| 143 | } |
||
| 144 | //felix |
||
| 145 | // If table has updated field values, update the table |
||
| 146 | if ($table->getUpdatedWhere()) { |
||
| 147 | $ret = $table->updateWhereValues($table) && $ret; |
||
| 148 | } |
||
| 149 | |||
| 150 | echo '</ul>'; |
||
| 151 | |||
| 152 | return $ret; |
||
| 153 | } |
||
| 155 |
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.