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 |
||
91 | public function createProduct(array $fields = array(), array $params = array(), $pending = false) { |
||
92 | $this->assureId(); |
||
93 | |||
94 | $param_types = array( |
||
95 | 'additional_image_urls' => 'list<string>', |
||
96 | 'android_app_name' => 'string', |
||
97 | 'android_class' => 'string', |
||
98 | 'android_package' => 'string', |
||
99 | 'android_url' => 'string', |
||
100 | 'availability' => 'availability_enum', |
||
101 | 'brand' => 'string', |
||
102 | 'category' => 'string', |
||
103 | 'checkout_url' => 'string', |
||
104 | 'color' => 'string', |
||
105 | 'condition' => 'condition_enum', |
||
106 | 'currency' => 'string', |
||
107 | 'custom_data' => 'map', |
||
108 | 'custom_label_0' => 'string', |
||
109 | 'custom_label_1' => 'string', |
||
110 | 'custom_label_2' => 'string', |
||
111 | 'custom_label_3' => 'string', |
||
112 | 'custom_label_4' => 'string', |
||
113 | 'description' => 'string', |
||
114 | 'expiration_date' => 'string', |
||
115 | 'gender' => 'gender_enum', |
||
116 | 'gtin' => 'string', |
||
117 | 'image_url' => 'string', |
||
118 | 'inventory' => 'unsigned int', |
||
119 | 'ios_app_name' => 'string', |
||
120 | 'ios_app_store_id' => 'unsigned int', |
||
121 | 'ios_url' => 'string', |
||
122 | 'ipad_app_name' => 'string', |
||
123 | 'ipad_app_store_id' => 'unsigned int', |
||
124 | 'ipad_url' => 'string', |
||
125 | 'iphone_app_name' => 'string', |
||
126 | 'iphone_app_store_id' => 'unsigned int', |
||
127 | 'iphone_url' => 'string', |
||
128 | 'manufacturer_part_number' => 'string', |
||
129 | 'material' => 'string', |
||
130 | 'name' => 'string', |
||
131 | 'ordering_index' => 'unsigned int', |
||
132 | 'pattern' => 'string', |
||
133 | 'price' => 'unsigned int', |
||
134 | 'product_type' => 'string', |
||
135 | 'retailer_id' => 'string', |
||
136 | 'sale_price' => 'unsigned int', |
||
137 | 'sale_price_end_date' => 'datetime', |
||
138 | 'sale_price_start_date' => 'datetime', |
||
139 | 'short_description' => 'string', |
||
140 | 'size' => 'string', |
||
141 | 'start_date' => 'string', |
||
142 | 'url' => 'string', |
||
143 | 'visibility' => 'visibility_enum', |
||
144 | 'windows_phone_app_id' => 'string', |
||
145 | 'windows_phone_app_name' => 'string', |
||
146 | 'windows_phone_url' => 'string', |
||
147 | ); |
||
148 | $enums = array( |
||
149 | 'availability_enum' => ProductItemAvailabilityValues::getInstance()->getValues(), |
||
150 | 'condition_enum' => ProductItemConditionValues::getInstance()->getValues(), |
||
151 | 'gender_enum' => ProductItemGenderValues::getInstance()->getValues(), |
||
152 | 'visibility_enum' => ProductItemVisibilityValues::getInstance()->getValues(), |
||
153 | ); |
||
154 | |||
155 | $request = new ApiRequest( |
||
156 | $this->api, |
||
157 | $this->data['id'], |
||
158 | RequestInterface::METHOD_POST, |
||
159 | '/products', |
||
160 | new ProductItem(), |
||
161 | 'EDGE', |
||
162 | ProductItem::getFieldsEnum()->getValues(), |
||
163 | new TypeChecker($param_types, $enums) |
||
164 | ); |
||
165 | $request->addParams($params); |
||
166 | $request->addFields($fields); |
||
167 | return $pending ? $request : $request->execute(); |
||
168 | } |
||
169 | |||
241 |