| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| 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 |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | $tableOptions = null; |
||
| 17 | if ($this->db->driverName === 'mysql') { |
||
| 18 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||
| 19 | } |
||
| 20 | |||
| 21 | $this->createTable('content', [ |
||
| 22 | 'id' => $this->primaryKey()->notNull()->append('AUTO_INCREMENT'), |
||
| 23 | 'name' => $this->string(64)->notNull(), |
||
| 24 | 'description' => $this->string(1024), |
||
| 25 | 'flow_id' => $this->integer()->notNull(), |
||
| 26 | 'type_id' => $this->string(45)->notNull(), |
||
| 27 | 'data' => $this->text(), |
||
| 28 | 'duration' => $this->integer()->notNull()->defaultValue(10), |
||
| 29 | 'start_ts' => $this->timestamp()->null(), |
||
| 30 | 'end_ts' => $this->timestamp()->null(), |
||
| 31 | 'add_ts' => $this->timestamp()->notNull()->defaultExpression('CURRENT_TIMESTAMP'), |
||
| 32 | 'enabled' => $this->boolean()->notNull()->defaultValue(true), |
||
| 33 | ], $tableOptions); |
||
| 34 | |||
| 35 | $this->createIndex( |
||
| 36 | 'fk_content_flow1_idx', |
||
| 37 | 'content', |
||
| 38 | 'flow_id' |
||
| 39 | ); |
||
| 40 | |||
| 41 | $this->createIndex( |
||
| 42 | 'fk_content_content_type1_idx', |
||
| 43 | 'content', |
||
| 44 | 'type_id' |
||
| 45 | ); |
||
| 46 | |||
| 47 | $this->addForeignKey( |
||
| 48 | 'fk_content_flow1', |
||
| 49 | 'content', |
||
| 50 | 'flow_id', |
||
| 51 | 'flow', |
||
| 52 | 'id', |
||
| 53 | 'CASCADE', |
||
| 54 | 'CASCADE' |
||
| 55 | ); |
||
| 56 | |||
| 57 | $this->addForeignKey( |
||
| 58 | 'fk_content_content_type1', |
||
| 59 | 'content', |
||
| 60 | 'type_id', |
||
| 61 | 'content_type', |
||
| 62 | 'id', |
||
| 63 | 'CASCADE', |
||
| 64 | 'CASCADE' |
||
| 65 | ); |
||
| 66 | } |
||
| 67 | |||
| 76 |