Conditions | 2 |
Paths | 2 |
Total Lines | 57 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
33 | public function safeUp() |
||
34 | { |
||
35 | $tableOptions = null; |
||
36 | if ($this->db->driverName === 'mysql') { |
||
37 | /* @link http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci */ |
||
38 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||
39 | } |
||
40 | |||
41 | // Tables |
||
42 | $this->createTable( |
||
43 | $this->primaryTableName, |
||
44 | [ |
||
45 | 'id' => $this->primaryKey()->unsigned(), |
||
46 | 'key' => $this->string()->notNull()->unique(), |
||
47 | ], |
||
48 | $tableOptions |
||
49 | ); |
||
50 | $this->createTable( |
||
51 | $this->translationTableName, |
||
52 | [ |
||
53 | 'id' => $this->primaryKey()->unsigned(), |
||
54 | 'templateId' => $this->integer()->unsigned()->notNull(), |
||
55 | 'language' => $this->string(16)->notNull(), |
||
56 | 'subject' => $this->string()->notNull(), |
||
57 | 'body' => $this->text()->notNull(), |
||
58 | 'hint' => $this->string(500), |
||
59 | ], |
||
60 | $tableOptions |
||
61 | ); |
||
62 | |||
63 | // Indexes |
||
64 | $this->createIndex( |
||
65 | 'idx-email_template-key', |
||
66 | $this->primaryTableName, |
||
67 | 'key', |
||
68 | true |
||
69 | ); |
||
70 | $this->createIndex( |
||
71 | 'idx-email_template_translation-templateId', |
||
72 | $this->primaryTableName, |
||
73 | 'templateId' |
||
74 | ); |
||
75 | $this->createIndex( |
||
76 | 'idx-email_template_translation-language', |
||
77 | $this->translationTableName, |
||
78 | 'language' |
||
79 | ); |
||
80 | |||
81 | // Foreign keys |
||
82 | $this->addForeignKey( |
||
83 | 'fk-email_template_translation-email_template', |
||
84 | $this->primaryTableName, |
||
85 | 'templateId', |
||
86 | $this->translationTableName, |
||
87 | 'id', |
||
88 | 'CASCADE', |
||
89 | 'CASCADE' |
||
90 | ); |
||
108 |