| Conditions | 2 |
| Paths | 2 |
| Total Lines | 75 |
| Code Lines | 58 |
| 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 |
||
| 16 | public function up() |
||
| 17 | { |
||
| 18 | $tableOptions = null; |
||
| 19 | |||
| 20 | if ($this->db->driverName === 'mysql') { |
||
| 21 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; |
||
| 22 | } |
||
| 23 | |||
| 24 | $this->createTable('{{%module}}', [ |
||
| 25 | 'id' => Schema::TYPE_PK, |
||
| 26 | 'name' => Schema::TYPE_STRING . '(64) NOT NULL', |
||
| 27 | 'title' => Schema::TYPE_TEXT . ' NOT NULL', |
||
| 28 | 'description' => Schema::TYPE_TEXT, |
||
| 29 | 'config' => Schema::TYPE_TEXT . ' NOT NULL', |
||
| 30 | 'status' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0', |
||
| 31 | 'directory' => Schema::TYPE_STRING . '(128) NOT NULL', |
||
| 32 | 'backend_bootstrap' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0', |
||
| 33 | 'frontend_bootstrap' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0', |
||
| 34 | 'date' => Schema::TYPE_DATETIME . ' NOT NULL', |
||
| 35 | 'modified' => Schema::TYPE_DATETIME . ' NOT NULL', |
||
| 36 | ], $tableOptions); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Insert data module |
||
| 40 | */ |
||
| 41 | $this->batchInsert('{{%module}}', [ |
||
| 42 | 'name', |
||
| 43 | 'title', |
||
| 44 | 'description', |
||
| 45 | 'config', |
||
| 46 | 'status', |
||
| 47 | 'directory', |
||
| 48 | 'backend_bootstrap', |
||
| 49 | 'frontend_bootstrap', |
||
| 50 | 'date', |
||
| 51 | 'modified', |
||
| 52 | ], [ |
||
| 53 | [ |
||
| 54 | 'toolbar', |
||
| 55 | 'Toolbar', |
||
| 56 | null, |
||
| 57 | '{"frontend":{"class":"modules\\\\toolbar\\\\frontend\\\\Module"}}', |
||
| 58 | 0, |
||
| 59 | 'toolbar', |
||
| 60 | 0, |
||
| 61 | 1, |
||
| 62 | '2015-09-11 03:14:57', |
||
| 63 | '2015-09-11 03:14:57', |
||
| 64 | ], |
||
| 65 | [ |
||
| 66 | 'sitemap', |
||
| 67 | 'Sitemap', |
||
| 68 | 'Module for sitemap', |
||
| 69 | '{"backend":{"class":"modules\\\\sitemap\\\\backend\\\\Module"},"frontend":{"class":"modules\\\\sitemap\\\\frontend\\\\Module"}}', |
||
| 70 | 0, |
||
| 71 | 'sitemap', |
||
| 72 | 0, |
||
| 73 | 1, |
||
| 74 | '2015-09-11 03:38:25', |
||
| 75 | '2015-09-11 03:38:25', |
||
| 76 | ], |
||
| 77 | [ |
||
| 78 | 'feed', |
||
| 79 | 'RSS Feed', |
||
| 80 | null, |
||
| 81 | '{"frontend":{"class":"modules\\\\feed\\\\frontend\\\\Module"}}', |
||
| 82 | 0, |
||
| 83 | 'feed', |
||
| 84 | 0, |
||
| 85 | 0, |
||
| 86 | '2015-09-11 03:38:53', |
||
| 87 | '2015-09-11 03:38:53', |
||
| 88 | ], |
||
| 89 | ]); |
||
| 90 | } |
||
| 91 | |||
| 100 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.