Conditions | 1 |
Paths | 1 |
Total Lines | 106 |
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 |
||
35 | public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
36 | { |
||
37 | $setup->startSetup(); |
||
38 | |||
39 | $productAttachments = $setup->getConnection()->newTable( |
||
40 | $setup->getTable(Attachment::MAIN_TABLE) |
||
41 | )->addColumn( |
||
42 | Attachment::ID, |
||
43 | Table::TYPE_INTEGER, |
||
44 | 11, |
||
45 | ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], |
||
46 | 'Id' |
||
47 | )->addColumn( |
||
48 | Attachment::PRODUCT_ID, |
||
49 | Table::TYPE_INTEGER, |
||
50 | 11, |
||
51 | ['unsigned' => true, 'nullable' => false], |
||
52 | 'Product id' |
||
53 | )->addColumn( |
||
54 | Attachment::SORT_ORDER, |
||
55 | Table::TYPE_INTEGER, |
||
56 | 11, |
||
57 | ['unsigned' => true, 'nullable' => false], |
||
58 | 'Sort order' |
||
59 | )->addColumn( |
||
60 | Attachment::ATTACHMENT_TYPE, |
||
61 | Table::TYPE_TEXT, |
||
62 | 21, |
||
63 | ['nullable' => false], |
||
64 | 'Type' |
||
65 | )->addColumn( |
||
66 | Attachment::ATTACHMENT_FILE, |
||
67 | Table::TYPE_TEXT, |
||
68 | 255, |
||
69 | ['nullable' => true], |
||
70 | 'File' |
||
71 | )->addColumn( |
||
72 | Attachment::ATTACHMENT_URL, |
||
73 | Table::TYPE_TEXT, |
||
74 | 255, |
||
75 | ['nullable' => true], |
||
76 | 'File' |
||
77 | )->addForeignKey( |
||
78 | $setup->getFkName( |
||
79 | $setup->getTable(Attachment::MAIN_TABLE), |
||
80 | Attachment::PRODUCT_ID, |
||
81 | $setup->getTable('catalog_product_entity'), |
||
82 | 'entity_id' |
||
83 | ), |
||
84 | Attachment::PRODUCT_ID, |
||
85 | $setup->getTable('catalog_product_entity'), |
||
86 | 'entity_id', |
||
87 | Table::ACTION_CASCADE |
||
88 | )->setComment( |
||
89 | 'Product attachments' |
||
90 | ); |
||
91 | |||
92 | $setup->getConnection()->createTable($productAttachments); |
||
93 | |||
94 | |||
95 | |||
96 | $productAttachmentsTitle = $setup->getConnection()->newTable( |
||
97 | $setup->getTable(Attachment::TITLE_TABLE) |
||
98 | )->addColumn( |
||
99 | Attachment::TITLE_ID, |
||
100 | Table::TYPE_INTEGER, |
||
101 | 11, |
||
102 | ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], |
||
103 | 'Id' |
||
104 | )->addColumn( |
||
105 | Attachment::ATTACHMENT_ID, |
||
106 | Table::TYPE_INTEGER, |
||
107 | 11, |
||
108 | ['unsigned' => true, 'nullable' => false], |
||
109 | 'Attachment id' |
||
110 | )->addColumn( |
||
111 | Attachment::STORE_ID, |
||
112 | Table::TYPE_INTEGER, |
||
113 | 11, |
||
114 | ['unsigned' => true, 'nullable' => false], |
||
115 | 'Store id' |
||
116 | )->addColumn( |
||
117 | Attachment::TITLE, |
||
118 | Table::TYPE_TEXT, |
||
119 | 120, |
||
120 | ['nullable' => false], |
||
121 | 'Title' |
||
122 | )->addForeignKey( |
||
123 | $setup->getFkName( |
||
124 | $setup->getTable(Attachment::TITLE_TABLE), |
||
125 | Attachment::ATTACHMENT_ID, |
||
126 | $setup->getTable(Attachment::MAIN_TABLE), |
||
127 | Attachment::ID |
||
128 | ), |
||
129 | Attachment::ATTACHMENT_ID, |
||
130 | $setup->getTable(Attachment::MAIN_TABLE), |
||
131 | Attachment::ID, |
||
132 | Table::ACTION_CASCADE |
||
133 | )->setComment( |
||
134 | 'Product attachments titles' |
||
135 | ); |
||
136 | |||
137 | $setup->getConnection()->createTable($productAttachmentsTitle); |
||
138 | |||
139 | $setup->endSetup(); |
||
140 | } |
||
141 | } |
||
142 |