Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 37 |
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 |
||
81 | public function down(Schema $schema) |
||
82 | { |
||
83 | // this down() migration is auto-generated, please modify it to your needs |
||
84 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
||
85 | |||
86 | // Deleting voip & teamspeak tables |
||
87 | $this->addSql('ALTER TABLE teamspeak_server DROP FOREIGN KEY FK_ACCB911EBF396750'); |
||
88 | $this->addSql('ALTER TABLE voip_server_instance DROP FOREIGN KEY FK_6AED3879EE279FF'); |
||
89 | $this->addSql('ALTER TABLE teamspeak_server_instance DROP FOREIGN KEY FK_4B1CC3D6BF396750'); |
||
90 | $this->addSql('DROP TABLE teamspeak_server'); |
||
91 | $this->addSql('DROP TABLE teamspeak_server_instance'); |
||
92 | $this->addSql('DROP TABLE voip_server'); |
||
93 | $this->addSql('DROP TABLE voip_server_instance'); |
||
94 | |||
95 | // Deleting the many-to-many join table between machine & group |
||
96 | $this->addSql('DROP TABLE machine_to_groups'); |
||
97 | |||
98 | // Reverting updates of existing tables |
||
99 | $this->addSql('ALTER TABLE game CHANGE map map VARCHAR(20) DEFAULT NULL'); |
||
100 | $this->addSql('ALTER TABLE machine ADD publicKey VARCHAR(255) DEFAULT NULL, CHANGE privateIp privateIp VARCHAR(15) DEFAULT NULL, CHANGE home home VARCHAR(255) DEFAULT NULL, CHANGE username user VARCHAR(16) NOT NULL, CHANGE privatekeyname privateKey VARCHAR(23) NOT NULL'); |
||
101 | $this->addSql('RENAME TABLE game_server TO gameserver'); |
||
102 | $this->addSql('ALTER TABLE gameserver DROP core, CHANGE installation_status installationStatus INT DEFAULT NULL'); |
||
103 | $this->addSql('ALTER TABLE gameserver_plugins DROP FOREIGN KEY FK_9B4F31881844E6B7'); |
||
104 | $this->addSql('ALTER TABLE gameserver_plugins ADD CONSTRAINT FK_9B4F31881844E6B7 FOREIGN KEY (server_id) REFERENCES gameserver (id)'); |
||
105 | $this->addSql('ALTER TABLE steam_server ADD core INT DEFAULT NULL, ADD hltvPort INT DEFAULT NULL'); |
||
106 | |||
107 | // Restoring old fos_user_{user,group,user_group} tables |
||
108 | $this->addSql('ALTER TABLE user_table DROP FOREIGN KEY FK_14EB741EFE54D947'); |
||
109 | $this->addSql('ALTER TABLE group_table DROP FOREIGN KEY FK_A605A421727ACA70'); |
||
110 | $this->addSql('RENAME TABLE user_table TO fos_user_user'); |
||
111 | $this->addSql('ALTER TABLE fos_user_user DROP group_id, DROP createdAt, DROP INDEX IDX_14EB741EFE54D947'); |
||
112 | $this->addSql('CREATE TABLE fos_user_user_group (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_B3C77447A76ED395 (user_id), INDEX IDX_B3C77447FE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
113 | $this->addSql('CREATE TABLE fos_user_group (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', UNIQUE INDEX UNIQ_583D1F3E5E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
114 | $this->addSql('ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447A76ED395 FOREIGN KEY (user_id) REFERENCES fos_user_user (id) ON DELETE CASCADE'); |
||
115 | $this->addSql('ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447FE54D947 FOREIGN KEY (group_id) REFERENCES fos_user_group (id) ON DELETE CASCADE'); |
||
116 | $this->addSql('DROP TABLE group_table'); |
||
117 | |||
118 | // Restoring acl tables |
||
119 | $this->addSql('CREATE TABLE acl_classes (id INT UNSIGNED AUTO_INCREMENT NOT NULL, class_type VARCHAR(200) NOT NULL, UNIQUE INDEX UNIQ_69DD750638A36066 (class_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
120 | $this->addSql('CREATE TABLE acl_security_identities (id INT UNSIGNED AUTO_INCREMENT NOT NULL, identifier VARCHAR(200) NOT NULL, username TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 (identifier, username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
121 | $this->addSql('CREATE TABLE acl_object_identities (id INT UNSIGNED AUTO_INCREMENT NOT NULL, parent_object_identity_id INT UNSIGNED DEFAULT NULL, class_id INT UNSIGNED NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 (object_identifier, class_id), INDEX IDX_9407E54977FA751A (parent_object_identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
122 | $this->addSql('CREATE TABLE acl_object_identity_ancestors (object_identity_id INT UNSIGNED NOT NULL, ancestor_id INT UNSIGNED NOT NULL, INDEX IDX_825DE2993D9AB4A6 (object_identity_id), INDEX IDX_825DE299C671CEA1 (ancestor_id), PRIMARY KEY(object_identity_id, ancestor_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
123 | $this->addSql('CREATE TABLE acl_entries (id INT UNSIGNED AUTO_INCREMENT NOT NULL, class_id INT UNSIGNED NOT NULL, object_identity_id INT UNSIGNED DEFAULT NULL, security_identity_id INT UNSIGNED NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order SMALLINT UNSIGNED NOT NULL, mask INT NOT NULL, granting TINYINT(1) NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success TINYINT(1) NOT NULL, audit_failure TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 (class_id, object_identity_id, field_name, ace_order), INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 (class_id, object_identity_id, security_identity_id), INDEX IDX_46C8B806EA000B10 (class_id), INDEX IDX_46C8B8063D9AB4A6 (object_identity_id), INDEX IDX_46C8B806DF9183C9 (security_identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
||
124 | // Restoring foreign keys |
||
125 | $this->addSql('ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE'); |
||
126 | $this->addSql('ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE'); |
||
127 | $this->addSql('ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE'); |
||
128 | $this->addSql('ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id)'); |
||
129 | $this->addSql('ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE'); |
||
130 | $this->addSql('ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE'); |
||
131 | } |
||
132 | |||
148 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: