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