| Conditions | 10 |
| Paths | 512 |
| Total Lines | 52 |
| Code Lines | 33 |
| 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 |
||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | $table = $schema->getTable('extra_field'); |
||
| 20 | if (false === $table->hasColumn('helper_text')) { |
||
| 21 | $this->addSql('ALTER TABLE extra_field ADD helper_text text DEFAULT NULL AFTER display_text'); |
||
| 22 | } |
||
| 23 | $this->addSql('ALTER TABLE extra_field_values CHANGE value value LONGTEXT DEFAULT NULL;'); |
||
| 24 | if (false === $table->hasColumn('description')) { |
||
| 25 | $this->addSql('ALTER TABLE extra_field ADD description LONGTEXT DEFAULT NULL'); |
||
| 26 | } |
||
| 27 | |||
| 28 | $table = $schema->getTable('extra_field_values'); |
||
| 29 | if (!$table->hasIndex('idx_efv_item')) { |
||
| 30 | $this->addSql('CREATE INDEX idx_efv_item ON extra_field_values (item_id)'); |
||
| 31 | } |
||
| 32 | |||
| 33 | $table = $schema->getTable('extra_field_option_rel_field_option'); |
||
| 34 | if (!$table->hasForeignKey('FK_8E04DF6B42C79BE5')) { |
||
| 35 | $this->addSql('ALTER TABLE extra_field_option_rel_field_option ADD CONSTRAINT FK_8E04DF6B42C79BE5 FOREIGN KEY (field_option_id) REFERENCES extra_field_options (id);'); |
||
| 36 | $this->addSql('CREATE INDEX IDX_8E04DF6B42C79BE5 ON extra_field_option_rel_field_option (field_option_id)'); |
||
| 37 | } |
||
| 38 | if (!$table->hasForeignKey('FK_8E04DF6BCFAFCECC')) { |
||
| 39 | $this->addSql('ALTER TABLE extra_field_option_rel_field_option ADD CONSTRAINT FK_8E04DF6BCFAFCECC FOREIGN KEY (related_field_option_id) REFERENCES extra_field_options (id);'); |
||
| 40 | $this->addSql('CREATE INDEX IDX_8E04DF6BCFAFCECC ON extra_field_option_rel_field_option (related_field_option_id);'); |
||
| 41 | } |
||
| 42 | if (!$table->hasForeignKey('FK_8E04DF6B443707B0')) { |
||
| 43 | $this->addSql('ALTER TABLE extra_field_option_rel_field_option ADD CONSTRAINT FK_8E04DF6B443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id);'); |
||
| 44 | $this->addSql('CREATE INDEX IDX_8E04DF6B443707B0 ON extra_field_option_rel_field_option (field_id);'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $table = $schema->getTable('extra_field_rel_tag'); |
||
| 48 | |||
| 49 | $this->addSql('ALTER TABLE extra_field_rel_tag CHANGE field_id field_id INT DEFAULT NULL'); |
||
| 50 | $this->addSql('ALTER TABLE extra_field_rel_tag CHANGE tag_id tag_id INT DEFAULT NULL'); |
||
| 51 | |||
| 52 | if (!$table->hasForeignKey('FK_F8817295443707B0')) { |
||
| 53 | $this->addSql('ALTER TABLE extra_field_rel_tag ADD CONSTRAINT FK_F8817295443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id) ON DELETE CASCADE'); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (!$table->hasForeignKey('FK_F8817295BAD26311')) { |
||
| 57 | $this->addSql( |
||
| 58 | 'ALTER TABLE extra_field_rel_tag ADD CONSTRAINT FK_F8817295BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE' |
||
| 59 | ); |
||
| 60 | } |
||
| 61 | |||
| 62 | $table = $schema->getTable('tag'); |
||
| 63 | $this->addSql('ALTER TABLE tag CHANGE field_id field_id INT DEFAULT NULL'); |
||
| 64 | if (!$table->hasForeignKey('FK_389B783443707B0')) { |
||
| 65 | $this->addSql( |
||
| 66 | 'ALTER TABLE tag ADD CONSTRAINT FK_389B783443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id) ON DELETE CASCADE' |
||
| 67 | ); |
||
| 68 | $this->addSql('CREATE INDEX IDX_389B783443707B0 ON tag (field_id)'); |
||
| 69 | } |
||
| 72 |