| Conditions | 12 |
| Paths | 459 |
| Total Lines | 52 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 86 | public function down(Schema $schema): void |
||
| 87 | { |
||
| 88 | $schemaManager = $this->connection->createSchemaManager(); |
||
| 89 | |||
| 90 | // Revert 'new_subscription_session_id' in the 'session_rel_user' table |
||
| 91 | if ($schemaManager->tablesExist('session_rel_user')) { |
||
| 92 | $sessionRelUserTable = $schemaManager->listTableColumns('session_rel_user'); |
||
| 93 | |||
| 94 | if (isset($sessionRelUserTable['new_subscription_session_id'])) { |
||
| 95 | $this->addSql("ALTER TABLE session_rel_user DROP COLUMN new_subscription_session_id"); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | // Revert changes in the 'session' table |
||
| 100 | if ($schemaManager->tablesExist('session')) { |
||
| 101 | $sessionTable = $schemaManager->listTableColumns('session'); |
||
| 102 | |||
| 103 | if (isset($sessionTable['parent_id'])) { |
||
| 104 | $this->addSql("ALTER TABLE session DROP COLUMN parent_id"); |
||
| 105 | } |
||
| 106 | if (isset($sessionTable['days_to_reinscription'])) { |
||
| 107 | $this->addSql("ALTER TABLE session DROP COLUMN days_to_reinscription"); |
||
| 108 | } |
||
| 109 | if (isset($sessionTable['last_repetition'])) { |
||
| 110 | $this->addSql("ALTER TABLE session DROP COLUMN last_repetition"); |
||
| 111 | } |
||
| 112 | if (isset($sessionTable['days_to_new_repetition'])) { |
||
| 113 | $this->addSql("ALTER TABLE session DROP COLUMN days_to_new_repetition"); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | // Revert 'validity_in_days' in the 'session' table |
||
| 118 | if ($schemaManager->tablesExist('session')) { |
||
| 119 | $sessionTable = $schemaManager->listTableColumns('session'); |
||
| 120 | |||
| 121 | if (isset($sessionTable['validity_in_days'])) { |
||
| 122 | $this->addSql("ALTER TABLE session DROP COLUMN validity_in_days"); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | |||
| 126 | // Re-add 'validity_in_days' to the 'c_lp' table |
||
| 127 | if ($schemaManager->tablesExist('c_lp')) { |
||
| 128 | $clpTable = $schemaManager->listTableColumns('c_lp'); |
||
| 129 | |||
| 130 | if (!isset($clpTable['validity_in_days'])) { |
||
| 131 | $this->addSql("ALTER TABLE c_lp ADD validity_in_days INT DEFAULT NULL"); |
||
| 132 | } |
||
| 133 | } |
||
| 134 | |||
| 135 | // Remove settings |
||
| 136 | $this->addSql("DELETE FROM settings WHERE variable = 'enable_auto_reinscription'"); |
||
| 137 | $this->addSql("DELETE FROM settings WHERE variable = 'enable_session_replication'"); |
||
| 138 | } |
||
| 140 |