| Conditions | 12 |
| Paths | 2048 |
| Total Lines | 52 |
| Code Lines | 33 |
| 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 |
||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | $table = $schema->getTable('c_tool'); |
||
| 20 | if (false === $table->hasForeignKey('FK_8456658091D79BD3')) { |
||
| 21 | $this->addSql( |
||
| 22 | 'ALTER TABLE c_tool ADD CONSTRAINT FK_8456658091D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)' |
||
| 23 | ); |
||
| 24 | } |
||
| 25 | $this->addSql('UPDATE c_tool SET name = "blog" WHERE name = "blog_management" '); |
||
| 26 | $this->addSql('UPDATE c_tool SET name = "agenda" WHERE name = "calendar_event" '); |
||
| 27 | //$this->addSql('UPDATE c_tool SET name = "maintenance" WHERE name = "course_maintenance" '); |
||
| 28 | //$this->addSql('UPDATE c_tool SET name = "assignment" WHERE name = "student_publication" '); |
||
| 29 | //$this->addSql('UPDATE c_tool SET name = "settings" WHERE name = "course_setting" '); |
||
| 30 | |||
| 31 | if (false === $table->hasColumn('tool_id')) { |
||
| 32 | $this->addSql('ALTER TABLE c_tool ADD tool_id INT NOT NULL'); |
||
| 33 | } |
||
| 34 | if (false === $table->hasColumn('position')) { |
||
| 35 | $this->addSql('ALTER TABLE c_tool ADD position INT NOT NULL'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($table->hasColumn('id')) { |
||
| 39 | $this->addSql('ALTER TABLE c_tool DROP id'); |
||
| 40 | } |
||
| 41 | if ($table->hasColumn('image')) { |
||
| 42 | $this->addSql('ALTER TABLE c_tool DROP image'); |
||
| 43 | } |
||
| 44 | if ($table->hasColumn('address')) { |
||
| 45 | $this->addSql('ALTER TABLE c_tool DROP address'); |
||
| 46 | } |
||
| 47 | if ($table->hasColumn('added_tool')) { |
||
| 48 | $this->addSql('ALTER TABLE c_tool DROP added_tool'); |
||
| 49 | } |
||
| 50 | if ($table->hasColumn('target')) { |
||
| 51 | $this->addSql('ALTER TABLE c_tool DROP target'); |
||
| 52 | } |
||
| 53 | if ($table->hasColumn('description')) { |
||
| 54 | $this->addSql('ALTER TABLE c_tool DROP description'); |
||
| 55 | } |
||
| 56 | if ($table->hasColumn('custom_icon')) { |
||
| 57 | $this->addSql('ALTER TABLE c_tool DROP custom_icon'); |
||
| 58 | } |
||
| 59 | |||
| 60 | if (false === $table->hasColumn('resource_node_id')) { |
||
| 61 | $this->addSql('ALTER TABLE c_tool ADD resource_node_id INT DEFAULT NULL'); |
||
| 62 | $this->addSql('UPDATE c_tool SET session_id = NULL WHERE session_id = 0'); |
||
| 63 | $this->addSql('UPDATE c_tool SET tool_id = (select id from tool where name = c_tool.name)'); |
||
| 64 | $this->addSql('ALTER TABLE c_tool ADD CONSTRAINT FK_84566580613FECDF FOREIGN KEY (session_id) REFERENCES session (id)'); |
||
| 65 | $this->addSql('ALTER TABLE c_tool ADD CONSTRAINT FK_845665808F7B22CC FOREIGN KEY (tool_id) REFERENCES tool (id)'); |
||
| 66 | $this->addSql('ALTER TABLE c_tool ADD CONSTRAINT FK_845665801BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
||
| 67 | $this->addSql('CREATE INDEX IDX_845665808F7B22CC ON c_tool (tool_id)'); |
||
| 68 | $this->addSql('CREATE UNIQUE INDEX UNIQ_845665801BAD783F ON c_tool (resource_node_id)'); |
||
| 69 | } |
||
| 76 |