| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 75 | 
| Code Lines | 69 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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 | ||
| 146 |   public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { | ||
| 147 | $this->assureId(); | ||
| 148 | |||
| 149 | $param_types = array( | ||
| 150 | 'additional_image_urls' => 'list<string>', | ||
| 151 | 'android_app_name' => 'string', | ||
| 152 | 'android_class' => 'string', | ||
| 153 | 'android_package' => 'string', | ||
| 154 | 'android_url' => 'string', | ||
| 155 | 'availability' => 'availability_enum', | ||
| 156 | 'brand' => 'string', | ||
| 157 | 'category' => 'string', | ||
| 158 | 'checkout_url' => 'string', | ||
| 159 | 'color' => 'string', | ||
| 160 | 'condition' => 'condition_enum', | ||
| 161 | 'currency' => 'string', | ||
| 162 | 'custom_data' => 'map', | ||
| 163 | 'custom_label_0' => 'string', | ||
| 164 | 'custom_label_1' => 'string', | ||
| 165 | 'custom_label_2' => 'string', | ||
| 166 | 'custom_label_3' => 'string', | ||
| 167 | 'custom_label_4' => 'string', | ||
| 168 | 'description' => 'string', | ||
| 169 | 'expiration_date' => 'string', | ||
| 170 | 'gender' => 'gender_enum', | ||
| 171 | 'gtin' => 'string', | ||
| 172 | 'image_url' => 'string', | ||
| 173 | 'inventory' => 'unsigned int', | ||
| 174 | 'ios_app_name' => 'string', | ||
| 175 | 'ios_app_store_id' => 'unsigned int', | ||
| 176 | 'ios_url' => 'string', | ||
| 177 | 'ipad_app_name' => 'string', | ||
| 178 | 'ipad_app_store_id' => 'unsigned int', | ||
| 179 | 'ipad_url' => 'string', | ||
| 180 | 'iphone_app_name' => 'string', | ||
| 181 | 'iphone_app_store_id' => 'unsigned int', | ||
| 182 | 'iphone_url' => 'string', | ||
| 183 | 'manufacturer_part_number' => 'string', | ||
| 184 | 'name' => 'string', | ||
| 185 | 'ordering_index' => 'unsigned int', | ||
| 186 | 'pattern' => 'string', | ||
| 187 | 'price' => 'unsigned int', | ||
| 188 | 'product_type' => 'string', | ||
| 189 | 'sale_price' => 'unsigned int', | ||
| 190 | 'sale_price_end_date' => 'datetime', | ||
| 191 | 'sale_price_start_date' => 'datetime', | ||
| 192 | 'size' => 'string', | ||
| 193 | 'start_date' => 'string', | ||
| 194 | 'url' => 'string', | ||
| 195 | 'visibility' => 'visibility_enum', | ||
| 196 | 'windows_phone_app_id' => 'unsigned int', | ||
| 197 | 'windows_phone_app_name' => 'string', | ||
| 198 | 'windows_phone_url' => 'string', | ||
| 199 | ); | ||
| 200 | $enums = array( | ||
| 201 | 'availability_enum' => ProductItemAvailabilityValues::getInstance()->getValues(), | ||
| 202 | 'condition_enum' => ProductItemConditionValues::getInstance()->getValues(), | ||
| 203 | 'gender_enum' => ProductItemGenderValues::getInstance()->getValues(), | ||
| 204 | 'visibility_enum' => ProductItemVisibilityValues::getInstance()->getValues(), | ||
| 205 | ); | ||
| 206 | |||
| 207 | $request = new ApiRequest( | ||
| 208 | $this->api, | ||
| 209 | $this->data['id'], | ||
| 210 | RequestInterface::METHOD_POST, | ||
| 211 | '/', | ||
| 212 | new ProductItem(), | ||
| 213 | 'NODE', | ||
| 214 | ProductItem::getFieldsEnum()->getValues(), | ||
| 215 | new TypeChecker($param_types, $enums) | ||
| 216 | ); | ||
| 217 | $request->addParams($params); | ||
| 218 | $request->addFields($fields); | ||
| 219 | return $pending ? $request : $request->execute(); | ||
| 220 | } | ||
| 221 | |||
| 223 |