| Conditions | 3 |
| Paths | 4 |
| Total Lines | 62 |
| Code Lines | 17 |
| 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 |
||
| 19 | public function up(Schema $schema): void |
||
| 20 | { |
||
| 21 | $schemaManager = $this->connection->createSchemaManager(); |
||
| 22 | |||
| 23 | if (!$schemaManager->tablesExist(['justification_document'])) { |
||
| 24 | $this->addSql(' |
||
| 25 | CREATE TABLE justification_document ( |
||
| 26 | id INT AUTO_INCREMENT NOT NULL, |
||
| 27 | code LONGTEXT DEFAULT NULL, |
||
| 28 | name LONGTEXT DEFAULT NULL, |
||
| 29 | validity_duration INT DEFAULT NULL, |
||
| 30 | comment LONGTEXT DEFAULT NULL, |
||
| 31 | date_manual_on INT DEFAULT NULL, |
||
| 32 | PRIMARY KEY(id) |
||
| 33 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC; |
||
| 34 | '); |
||
| 35 | } else { |
||
| 36 | $this->addSql(' |
||
| 37 | ALTER TABLE justification_document |
||
| 38 | CHANGE id id INT AUTO_INCREMENT NOT NULL, |
||
| 39 | CHANGE code code LONGTEXT DEFAULT NULL, |
||
| 40 | CHANGE name name LONGTEXT DEFAULT NULL, |
||
| 41 | CHANGE comment comment LONGTEXT DEFAULT NULL; |
||
| 42 | '); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (!$schemaManager->tablesExist(['justification_document_rel_users'])) { |
||
| 46 | $this->addSql(' |
||
| 47 | CREATE TABLE justification_document_rel_users ( |
||
| 48 | id INT AUTO_INCREMENT NOT NULL, |
||
| 49 | justification_document_id INT DEFAULT NULL, |
||
| 50 | user_id INT DEFAULT NULL, |
||
| 51 | file_path VARCHAR(255) DEFAULT NULL, |
||
| 52 | date_validity DATE DEFAULT NULL, |
||
| 53 | INDEX IDX_D1BB19421F2B6144 (justification_document_id), |
||
| 54 | INDEX IDX_D1BB1942A76ED395 (user_id), |
||
| 55 | PRIMARY KEY(id) |
||
| 56 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC; |
||
| 57 | '); |
||
| 58 | } else { |
||
| 59 | $this->addSql(' |
||
| 60 | ALTER TABLE justification_document_rel_users |
||
| 61 | CHANGE id id INT AUTO_INCREMENT NOT NULL; |
||
| 62 | '); |
||
| 63 | |||
| 64 | $this->addSql('ALTER TABLE justification_document_rel_users DROP FOREIGN KEY IF EXISTS FK_D1BB1942A76ED395;'); |
||
| 65 | $this->addSql('ALTER TABLE justification_document_rel_users DROP FOREIGN KEY IF EXISTS FK_D1BB19421F2B6144;'); |
||
| 66 | |||
| 67 | $this->addSql('DROP INDEX IF EXISTS IDX_D1BB19421F2B6144 ON justification_document_rel_users;'); |
||
| 68 | $this->addSql('DROP INDEX IF EXISTS IDX_D1BB1942A76ED395 ON justification_document_rel_users;'); |
||
| 69 | } |
||
| 70 | |||
| 71 | $this->addSql('CREATE INDEX IDX_D1BB19421F2B6144 ON justification_document_rel_users (justification_document_id);'); |
||
| 72 | $this->addSql('CREATE INDEX IDX_D1BB1942A76ED395 ON justification_document_rel_users (user_id);'); |
||
| 73 | |||
| 74 | $this->addSql(' |
||
| 75 | ALTER TABLE justification_document_rel_users |
||
| 76 | ADD CONSTRAINT FK_D1BB1942A76ED395 FOREIGN KEY (user_id) |
||
| 77 | REFERENCES user (id) ON DELETE CASCADE; |
||
| 78 | '); |
||
| 79 | |||
| 80 | $this->addSql(' |
||
| 81 | ALTER TABLE justification_document_rel_users |
||
| 122 |