| Conditions | 9 |
| Paths | 36 |
| Total Lines | 58 |
| Code Lines | 29 |
| 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 |
||
| 77 | public function down(Schema $schema): void |
||
| 78 | { |
||
| 79 | // --- attempt_file --- |
||
| 80 | if ($schema->hasTable('attempt_file')) { |
||
| 81 | $table = $schema->getTable('attempt_file'); |
||
| 82 | |||
| 83 | if ($table->hasColumn('resource_node_id')) { |
||
| 84 | // Drop FK if it exists. |
||
| 85 | if ($table->hasForeignKey('FK_ATTEMPT_FILE_RESOURCE_NODE')) { |
||
| 86 | $this->addSql( |
||
| 87 | 'ALTER TABLE attempt_file |
||
| 88 | DROP FOREIGN KEY FK_ATTEMPT_FILE_RESOURCE_NODE' |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | |||
| 92 | // Drop index if it exists. |
||
| 93 | if ($table->hasIndex('IDX_ATTEMPT_FILE_RESOURCE_NODE')) { |
||
| 94 | $this->addSql( |
||
| 95 | 'DROP INDEX IDX_ATTEMPT_FILE_RESOURCE_NODE |
||
| 96 | ON attempt_file' |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | // Drop the column. |
||
| 101 | $this->addSql( |
||
| 102 | 'ALTER TABLE attempt_file |
||
| 103 | DROP COLUMN resource_node_id' |
||
| 104 | ); |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | // --- attempt_feedback --- |
||
| 109 | if ($schema->hasTable('attempt_feedback')) { |
||
| 110 | $table = $schema->getTable('attempt_feedback'); |
||
| 111 | |||
| 112 | if ($table->hasColumn('resource_node_id')) { |
||
| 113 | if ($table->hasForeignKey('FK_ATTEMPT_FEEDBACK_RESOURCE_NODE')) { |
||
| 114 | $this->addSql( |
||
| 115 | 'ALTER TABLE attempt_feedback |
||
| 116 | DROP FOREIGN KEY FK_ATTEMPT_FEEDBACK_RESOURCE_NODE' |
||
| 117 | ); |
||
| 118 | } |
||
| 119 | |||
| 120 | if ($table->hasIndex('IDX_ATTEMPT_FEEDBACK_RESOURCE_NODE')) { |
||
| 121 | $this->addSql( |
||
| 122 | 'DROP INDEX IDX_ATTEMPT_FEEDBACK_RESOURCE_NODE |
||
| 123 | ON attempt_feedback' |
||
| 124 | ); |
||
| 125 | } |
||
| 126 | |||
| 127 | $this->addSql( |
||
| 128 | 'ALTER TABLE attempt_feedback |
||
| 129 | DROP COLUMN resource_node_id' |
||
| 130 | ); |
||
| 131 | } |
||
| 132 | } |
||
| 133 | |||
| 134 | $this->removeNewResourceTypes(); |
||
| 135 | } |
||
| 188 |