| Conditions | 2 |
| Paths | 2 |
| Total Lines | 74 |
| Code Lines | 64 |
| 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 |
||
| 15 | public function upgrade(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context) |
||
| 16 | { |
||
| 17 | $installer = $setup; |
||
| 18 | $installer->startSetup(); |
||
| 19 | |||
| 20 | if (version_compare($context->getVersion(), '1.0.1', '<')) { |
||
| 21 | |||
| 22 | $table = $installer->getConnection()->newTable( |
||
| 23 | $installer->getTable('firegento_devdashboard_config') |
||
| 24 | )->addColumn( |
||
| 25 | 'firegento_devdashboard_config_id', |
||
| 26 | Table::TYPE_INTEGER, |
||
| 27 | null, |
||
| 28 | ['identity' => true, 'nullable' => false, 'primary' => true, 'unsigned' => true,], |
||
| 29 | 'Entity ID' |
||
| 30 | )->addColumn( |
||
| 31 | 'user_id', |
||
| 32 | Table::TYPE_INTEGER, |
||
| 33 | null, |
||
| 34 | ['unsigned' => true, 'nullable' => false], |
||
| 35 | 'Admin User Id' |
||
| 36 | )->addColumn( |
||
| 37 | 'creation_time', |
||
| 38 | Table::TYPE_TIMESTAMP, |
||
| 39 | null, |
||
| 40 | ['nullable' => false, 'default' => Table::TIMESTAMP_INIT,], |
||
| 41 | 'Creation Time' |
||
| 42 | )->addColumn( |
||
| 43 | 'update_time', |
||
| 44 | Table::TYPE_TIMESTAMP, |
||
| 45 | null, |
||
| 46 | ['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE,], |
||
| 47 | 'Modification Time' |
||
| 48 | )->addColumn( |
||
| 49 | 'configuration', |
||
| 50 | Table::TYPE_TEXT, |
||
| 51 | null, |
||
| 52 | [], |
||
| 53 | 'Configuration' |
||
| 54 | )->addColumn( |
||
| 55 | 'use_devdashboard', |
||
| 56 | Table::TYPE_SMALLINT, |
||
| 57 | null, |
||
| 58 | ['nullable' => false, 'default' => '0',], |
||
| 59 | 'Use Developer Dashboard' |
||
| 60 | )->addColumn( |
||
| 61 | 'is_active', |
||
| 62 | Table::TYPE_SMALLINT, |
||
| 63 | null, |
||
| 64 | ['nullable' => false, 'default' => '1',], |
||
| 65 | 'Use Developer Dashboard' |
||
| 66 | )->addForeignKey( |
||
| 67 | $installer->getFkName( |
||
| 68 | 'firegento_devdashboard_config', |
||
| 69 | 'user_id', |
||
| 70 | 'admin_user', |
||
| 71 | 'user_id' |
||
| 72 | ), |
||
| 73 | 'user_id', |
||
| 74 | $installer->getTable('admin_user'), |
||
| 75 | 'user_id', |
||
| 76 | Table::ACTION_CASCADE |
||
| 77 | )->addIndex( |
||
| 78 | $installer->getIdxName( |
||
| 79 | 'firegento_devdashboard_config', |
||
| 80 | ['user_id'], |
||
| 81 | AdapterInterface::INDEX_TYPE_INDEX), |
||
| 82 | ['user_id'] |
||
| 83 | |||
| 84 | ); |
||
| 85 | $installer->getConnection()->createTable($table); |
||
| 86 | } |
||
| 87 | |||
| 88 | $installer->endSetup(); |
||
| 89 | } |
||
| 91 |