Conditions | 2 |
Paths | 2 |
Total Lines | 78 |
Code Lines | 72 |
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 |
||
114 | public function createProduct(array $fields = array(), array $params = array(), $pending = false) { |
||
115 | $this->assureId(); |
||
116 | |||
117 | $param_types = array( |
||
118 | 'additional_image_urls' => 'list<string>', |
||
119 | 'android_app_name' => 'string', |
||
120 | 'android_class' => 'string', |
||
121 | 'android_package' => 'string', |
||
122 | 'android_url' => 'string', |
||
123 | 'availability' => 'availability_enum', |
||
124 | 'brand' => 'string', |
||
125 | 'category' => 'string', |
||
126 | 'checkout_url' => 'string', |
||
127 | 'color' => 'string', |
||
128 | 'condition' => 'condition_enum', |
||
129 | 'currency' => 'string', |
||
130 | 'custom_data' => 'map', |
||
131 | 'custom_label_0' => 'string', |
||
132 | 'custom_label_1' => 'string', |
||
133 | 'custom_label_2' => 'string', |
||
134 | 'custom_label_3' => 'string', |
||
135 | 'custom_label_4' => 'string', |
||
136 | 'description' => 'string', |
||
137 | 'expiration_date' => 'string', |
||
138 | 'gender' => 'gender_enum', |
||
139 | 'gtin' => 'string', |
||
140 | 'image_url' => 'string', |
||
141 | 'inventory' => 'unsigned int', |
||
142 | 'ios_app_name' => 'string', |
||
143 | 'ios_app_store_id' => 'unsigned int', |
||
144 | 'ios_url' => 'string', |
||
145 | 'ipad_app_name' => 'string', |
||
146 | 'ipad_app_store_id' => 'unsigned int', |
||
147 | 'ipad_url' => 'string', |
||
148 | 'iphone_app_name' => 'string', |
||
149 | 'iphone_app_store_id' => 'unsigned int', |
||
150 | 'iphone_url' => 'string', |
||
151 | 'manufacturer_part_number' => 'string', |
||
152 | 'material' => 'string', |
||
153 | 'name' => 'string', |
||
154 | 'ordering_index' => 'unsigned int', |
||
155 | 'pattern' => 'string', |
||
156 | 'price' => 'unsigned int', |
||
157 | 'product_type' => 'string', |
||
158 | 'retailer_id' => 'string', |
||
159 | 'sale_price' => 'unsigned int', |
||
160 | 'sale_price_end_date' => 'datetime', |
||
161 | 'sale_price_start_date' => 'datetime', |
||
162 | 'short_description' => 'string', |
||
163 | 'size' => 'string', |
||
164 | 'start_date' => 'string', |
||
165 | 'url' => 'string', |
||
166 | 'visibility' => 'visibility_enum', |
||
167 | 'windows_phone_app_id' => 'unsigned int', |
||
168 | 'windows_phone_app_name' => 'string', |
||
169 | 'windows_phone_url' => 'string', |
||
170 | ); |
||
171 | $enums = array( |
||
172 | 'availability_enum' => ProductItemAvailabilityValues::getInstance()->getValues(), |
||
173 | 'condition_enum' => ProductItemConditionValues::getInstance()->getValues(), |
||
174 | 'gender_enum' => ProductItemGenderValues::getInstance()->getValues(), |
||
175 | 'visibility_enum' => ProductItemVisibilityValues::getInstance()->getValues(), |
||
176 | ); |
||
177 | |||
178 | $request = new ApiRequest( |
||
179 | $this->api, |
||
180 | $this->data['id'], |
||
181 | RequestInterface::METHOD_POST, |
||
182 | '/products', |
||
183 | new ProductItem(), |
||
184 | 'EDGE', |
||
185 | ProductItem::getFieldsEnum()->getValues(), |
||
186 | new TypeChecker($param_types, $enums) |
||
187 | ); |
||
188 | $request->addParams($params); |
||
189 | $request->addFields($fields); |
||
190 | return $pending ? $request : $request->execute(); |
||
191 | } |
||
192 | |||
264 |