| Conditions | 12 |
| Paths | 2048 |
| Total Lines | 75 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 19 | public function up(Schema $schema): void |
||
| 20 | { |
||
| 21 | $table = $schema->getTable('c_calendar_event'); |
||
| 22 | if (false === $table->hasColumn('resource_node_id')) { |
||
| 23 | $this->addSql('ALTER TABLE c_calendar_event ADD resource_node_id INT DEFAULT NULL'); |
||
| 24 | $this->addSql( |
||
| 25 | 'ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A0622581EE3A445A FOREIGN KEY (parent_event_id) REFERENCES c_calendar_event (iid)' |
||
| 26 | ); |
||
| 27 | $this->addSql( |
||
| 28 | 'ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A06225811BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
||
| 29 | ); |
||
| 30 | $this->addSql('CREATE INDEX IDX_A0622581EE3A445A ON c_calendar_event (parent_event_id)'); |
||
| 31 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A06225811BAD783F ON c_calendar_event (resource_node_id)'); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($table->hasIndex('course')) { |
||
| 35 | $this->addSql('DROP INDEX course ON c_calendar_event'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($table->hasIndex('session_id')) { |
||
| 39 | $this->addSql('DROP INDEX session_id ON c_calendar_event'); |
||
| 40 | } |
||
| 41 | |||
| 42 | $table = $schema->getTable('c_calendar_event_attachment'); |
||
| 43 | if ($table->hasIndex('course')) { |
||
| 44 | $this->addSql('DROP INDEX course ON c_calendar_event_attachment'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->addSql('ALTER TABLE c_calendar_event_attachment CHANGE agenda_id agenda_id INT DEFAULT NULL'); |
||
| 48 | |||
| 49 | if (false === $table->hasColumn('resource_node_id')) { |
||
| 50 | $this->addSql('ALTER TABLE c_calendar_event_attachment ADD resource_node_id INT DEFAULT NULL'); |
||
| 51 | $this->addSql( |
||
| 52 | 'ALTER TABLE c_calendar_event_attachment ADD CONSTRAINT FK_DDD745A6EA67784A FOREIGN KEY (agenda_id) REFERENCES c_calendar_event (iid) ON DELETE CASCADE' |
||
| 53 | ); |
||
| 54 | $this->addSql( |
||
| 55 | 'ALTER TABLE c_calendar_event_attachment ADD CONSTRAINT FK_DDD745A61BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE' |
||
| 56 | ); |
||
| 57 | $this->addSql('CREATE INDEX IDX_DDD745A6EA67784A ON c_calendar_event_attachment (agenda_id)'); |
||
| 58 | $this->addSql( |
||
| 59 | 'CREATE UNIQUE INDEX UNIQ_DDD745A61BAD783F ON c_calendar_event_attachment (resource_node_id)' |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | |||
| 63 | $table = $schema->getTable('c_calendar_event_repeat'); |
||
| 64 | $this->addSql('ALTER TABLE c_calendar_event_repeat CHANGE cal_id cal_id INT DEFAULT NULL'); |
||
| 65 | if (false === $table->hasForeignKey('FK_86FD1CA87300D633')) { |
||
| 66 | $this->addSql( |
||
| 67 | 'ALTER TABLE c_calendar_event_repeat ADD CONSTRAINT FK_86FD1CA87300D633 FOREIGN KEY (cal_id) REFERENCES c_calendar_event (iid)' |
||
| 68 | ); |
||
| 69 | } |
||
| 70 | if (false === $table->hasIndex('IDX_86FD1CA87300D633')) { |
||
| 71 | $this->addSql('CREATE INDEX IDX_86FD1CA87300D633 ON c_calendar_event_repeat (cal_id)'); |
||
| 72 | } |
||
| 73 | |||
| 74 | if ($table->hasIndex('course')) { |
||
| 75 | $this->addSql('DROP INDEX course ON c_calendar_event_repeat'); |
||
| 76 | } |
||
| 77 | |||
| 78 | $table = $schema->getTable('c_calendar_event_repeat_not'); |
||
| 79 | |||
| 80 | if ($table->hasIndex('course')) { |
||
| 81 | $this->addSql('DROP INDEX course ON c_calendar_event_repeat_not'); |
||
| 82 | } |
||
| 83 | |||
| 84 | if (false === $table->hasForeignKey('FK_7D4436947300D633')) { |
||
| 85 | $this->addSql( |
||
| 86 | 'ALTER TABLE c_calendar_event_repeat_not ADD CONSTRAINT FK_7D4436947300D633 FOREIGN KEY (cal_id) REFERENCES c_calendar_event (iid)' |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | |||
| 90 | $this->addSql('ALTER TABLE c_calendar_event_repeat_not CHANGE cal_id cal_id INT DEFAULT NULL'); |
||
| 91 | |||
| 92 | if (false === $table->hasIndex('IDX_7D4436947300D633')) { |
||
| 93 | $this->addSql('CREATE INDEX IDX_7D4436947300D633 ON c_calendar_event_repeat_not (cal_id)'); |
||
| 94 | } |
||
| 101 |