| Conditions | 11 |
| Paths | 255 |
| Total Lines | 65 |
| Code Lines | 21 |
| 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 |
||
| 19 | public function up(Schema $schema): void |
||
| 20 | { |
||
| 21 | $schemaManager = $this->connection->createSchemaManager(); |
||
| 22 | |||
| 23 | if ($schema->hasTable('lti_external_tool')) { |
||
| 24 | $foreignKeys = $schemaManager->listTableForeignKeys('lti_external_tool'); |
||
| 25 | |||
| 26 | if (!$this->hasForeignKey($foreignKeys, 'FK_DB0E04E41BAD783F')) { |
||
| 27 | $this->addSql(' |
||
| 28 | ALTER TABLE lti_external_tool |
||
| 29 | ADD CONSTRAINT FK_DB0E04E41BAD783F FOREIGN KEY (resource_node_id) |
||
| 30 | REFERENCES resource_node (id) ON DELETE CASCADE; |
||
| 31 | '); |
||
| 32 | } |
||
| 33 | |||
| 34 | if (!$this->hasForeignKey($foreignKeys, 'FK_DB0E04E491D79BD3')) { |
||
| 35 | $this->addSql(' |
||
| 36 | ALTER TABLE lti_external_tool |
||
| 37 | ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) |
||
| 38 | REFERENCES course (id); |
||
| 39 | '); |
||
| 40 | } |
||
| 41 | |||
| 42 | if (!$this->hasForeignKey($foreignKeys, 'FK_DB0E04E482F80D8B')) { |
||
| 43 | $this->addSql(' |
||
| 44 | ALTER TABLE lti_external_tool |
||
| 45 | ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) |
||
| 46 | REFERENCES gradebook_evaluation (id) ON DELETE SET NULL; |
||
| 47 | '); |
||
| 48 | } |
||
| 49 | |||
| 50 | if (!$this->hasForeignKey($foreignKeys, 'FK_DB0E04E4727ACA70')) { |
||
| 51 | $this->addSql(' |
||
| 52 | ALTER TABLE lti_external_tool |
||
| 53 | ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id) |
||
| 54 | REFERENCES lti_external_tool (id); |
||
| 55 | '); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($schema->hasTable('lti_token')) { |
||
| 60 | $foreignKeys = $schemaManager->listTableForeignKeys('lti_token'); |
||
| 61 | |||
| 62 | if (!$this->hasForeignKey($foreignKeys, 'FK_EA71C468F7B22CC')) { |
||
| 63 | $this->addSql(' |
||
| 64 | ALTER TABLE lti_token |
||
| 65 | ADD CONSTRAINT FK_EA71C468F7B22CC FOREIGN KEY (tool_id) |
||
| 66 | REFERENCES lti_external_tool (id) ON DELETE CASCADE; |
||
| 67 | '); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | if ($schema->hasTable('lti_lineitem')) { |
||
| 72 | $foreignKeys = $schemaManager->listTableForeignKeys('lti_lineitem'); |
||
| 73 | |||
| 74 | if (!$this->hasForeignKey($foreignKeys, 'FK_5C76B75D8F7B22CC')) { |
||
| 75 | $this->addSql(' |
||
| 76 | ALTER TABLE lti_lineitem |
||
| 77 | ADD CONSTRAINT FK_5C76B75D8F7B22CC FOREIGN KEY (tool_id) |
||
| 78 | REFERENCES lti_external_tool (id) ON DELETE CASCADE; |
||
| 79 | '); |
||
| 80 | } |
||
| 81 | |||
| 82 | if (!$this->hasForeignKey($foreignKeys, 'FK_5C76B75D1323A575')) { |
||
| 83 | $this->addSql(' |
||
| 84 | ALTER TABLE lti_lineitem |
||
| 104 |