Passed
Branch request_builder (c1031c)
by Jens
08:30
created

CartsActionBuilder   B

Complexity

Total Complexity 41

Size/Duplication

Total Lines 328
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 41
dl 0
loc 328
ccs 82
cts 82
cp 1
rs 8.2769
c 0
b 0
f 0

41 Methods

Rating   Name   Duplication   Size   Complexity  
A changeTaxRoundingMode() 0 3 1
A removeLineItem() 0 3 1
A setShippingMethodTaxAmount() 0 3 1
A setCustomerGroup() 0 3 1
A setCountry() 0 3 1
A setLineItemCustomType() 0 3 1
A setCustomLineItemCustomField() 0 3 1
A setDeleteDaysAfterLastModification() 0 3 1
A changeLineItemQuantity() 0 3 1
A changeCustomLineItemMoney() 0 3 1
A removePayment() 0 3 1
A setCustomShippingMethod() 0 3 1
A setLineItemTotalPrice() 0 3 1
A setCustomLineItemTaxRate() 0 3 1
A removeCustomLineItem() 0 3 1
A setCartTotalTax() 0 3 1
A setShippingMethodTaxRate() 0 3 1
A changeTaxMode() 0 3 1
A setShippingRateInput() 0 3 1
A setCustomLineItemCustomType() 0 3 1
A setCustomerEmail() 0 3 1
A setLineItemTaxRate() 0 3 1
A changeTaxCalculationMode() 0 3 1
A removeDiscountCode() 0 3 1
A addPayment() 0 3 1
A setLineItemCustomField() 0 3 1
A addLineItem() 0 3 1
A addDiscountCode() 0 3 1
A setShippingAddress() 0 3 1
A recalculate() 0 3 1
A setAnonymousId() 0 3 1
A setLineItemTaxAmount() 0 3 1
A setLineItemPrice() 0 3 1
A changeCustomLineItemQuantity() 0 3 1
A setShippingMethod() 0 3 1
A setCustomLineItemTaxAmount() 0 3 1
A setLocale() 0 3 1
A addCustomLineItem() 0 3 1
A addShoppingList() 0 3 1
A setBillingAddress() 0 3 1
A setCustomerId() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like CartsActionBuilder often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use CartsActionBuilder, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Commercetools\Core\Builder\Update;
4
5
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomFieldAction;
6
use Commercetools\Core\Request\Carts\Command\CartAddPaymentAction;
7
use Commercetools\Core\Request\Carts\Command\CartRemoveLineItemAction;
8
use Commercetools\Core\Request\Carts\Command\CartRemoveCustomLineItemAction;
9
use Commercetools\Core\Request\Carts\Command\CartSetDeleteDaysAfterLastModificationAction;
10
use Commercetools\Core\Request\Carts\Command\CartSetLineItemPriceAction;
11
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTaxAmountAction;
12
use Commercetools\Core\Request\Carts\Command\CartRemoveDiscountCodeAction;
13
use Commercetools\Core\Request\Carts\Command\CartSetShippingAddressAction;
14
use Commercetools\Core\Request\Carts\Command\CartChangeCustomLineItemMoneyAction;
15
use Commercetools\Core\Request\Carts\Command\CartSetCustomerEmailAction;
16
use Commercetools\Core\Request\Carts\Command\CartSetLocaleAction;
17
use Commercetools\Core\Request\Carts\Command\CartSetCustomShippingMethodAction;
18
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemCustomFieldAction;
19
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTaxRateAction;
20
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodTaxRateAction;
21
use Commercetools\Core\Request\Carts\Command\CartAddCustomLineItemAction;
22
use Commercetools\Core\Request\Carts\Command\CartChangeTaxModeAction;
23
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemTaxRateAction;
24
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTotalPriceAction;
25
use Commercetools\Core\Request\Carts\Command\CartSetCartTotalTaxAction;
26
use Commercetools\Core\Request\Carts\Command\CartChangeLineItemQuantityAction;
27
use Commercetools\Core\Request\Carts\Command\CartRecalculateAction;
28
use Commercetools\Core\Request\Carts\Command\CartSetCustomerGroupAction;
29
use Commercetools\Core\Request\Carts\Command\CartSetBillingAddressAction;
30
use Commercetools\Core\Request\Carts\Command\CartSetAnonymousIdAction;
31
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodAction;
32
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomTypeAction;
33
use Commercetools\Core\Request\Carts\Command\CartAddLineItemAction;
34
use Commercetools\Core\Request\Carts\Command\CartSetCustomerIdAction;
35
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemTaxAmountAction;
36
use Commercetools\Core\Request\Carts\Command\CartAddShoppingListAction;
37
use Commercetools\Core\Request\Carts\Command\CartAddDiscountCodeAction;
38
use Commercetools\Core\Request\Carts\Command\CartChangeCustomLineItemQuantityAction;
39
use Commercetools\Core\Request\Carts\Command\CartSetShippingRateInputAction;
40
use Commercetools\Core\Request\Carts\Command\CartSetCountryAction;
41
use Commercetools\Core\Request\Carts\Command\CartChangeTaxRoundingModeAction;
42
use Commercetools\Core\Request\Carts\Command\CartRemovePaymentAction;
43
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodTaxAmountAction;
44
use Commercetools\Core\Request\Carts\Command\CartChangeTaxCalculationModeAction;
45
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemCustomTypeAction;
46
47
class CartsActionBuilder
48
{
49
    /**
50
     * @return CartSetLineItemCustomFieldAction
51
     */
52 1
    public function setLineItemCustomField()
53
    {
54 1
        return CartSetLineItemCustomFieldAction::of();
55
    }
56
57
    /**
58
     * @return CartAddPaymentAction
59
     */
60 1
    public function addPayment()
61
    {
62 1
        return CartAddPaymentAction::of();
63
    }
64
65
    /**
66
     * @return CartRemoveLineItemAction
67
     */
68 1
    public function removeLineItem()
69
    {
70 1
        return CartRemoveLineItemAction::of();
71
    }
72
73
    /**
74
     * @return CartRemoveCustomLineItemAction
75
     */
76 1
    public function removeCustomLineItem()
77
    {
78 1
        return CartRemoveCustomLineItemAction::of();
79
    }
80
81
    /**
82
     * @return CartSetDeleteDaysAfterLastModificationAction
83
     */
84 1
    public function setDeleteDaysAfterLastModification()
85
    {
86 1
        return CartSetDeleteDaysAfterLastModificationAction::of();
87
    }
88
89
    /**
90
     * @return CartSetLineItemPriceAction
91
     */
92 1
    public function setLineItemPrice()
93
    {
94 1
        return CartSetLineItemPriceAction::of();
95
    }
96
97
    /**
98
     * @return CartSetLineItemTaxAmountAction
99
     */
100 1
    public function setLineItemTaxAmount()
101
    {
102 1
        return CartSetLineItemTaxAmountAction::of();
103
    }
104
105
    /**
106
     * @return CartRemoveDiscountCodeAction
107
     */
108 1
    public function removeDiscountCode()
109
    {
110 1
        return CartRemoveDiscountCodeAction::of();
111
    }
112
113
    /**
114
     * @return CartSetShippingAddressAction
115
     */
116 1
    public function setShippingAddress()
117
    {
118 1
        return CartSetShippingAddressAction::of();
119
    }
120
121
    /**
122
     * @return CartChangeCustomLineItemMoneyAction
123
     */
124 1
    public function changeCustomLineItemMoney()
125
    {
126 1
        return CartChangeCustomLineItemMoneyAction::of();
127
    }
128
129
    /**
130
     * @return CartSetCustomerEmailAction
131
     */
132 1
    public function setCustomerEmail()
133
    {
134 1
        return CartSetCustomerEmailAction::of();
135
    }
136
137
    /**
138
     * @return CartSetLocaleAction
139
     */
140 1
    public function setLocale()
141
    {
142 1
        return CartSetLocaleAction::of();
143
    }
144
145
    /**
146
     * @return CartSetCustomShippingMethodAction
147
     */
148 1
    public function setCustomShippingMethod()
149
    {
150 1
        return CartSetCustomShippingMethodAction::of();
151
    }
152
153
    /**
154
     * @return CartSetCustomLineItemCustomFieldAction
155
     */
156 1
    public function setCustomLineItemCustomField()
157
    {
158 1
        return CartSetCustomLineItemCustomFieldAction::of();
159
    }
160
161
    /**
162
     * @return CartSetLineItemTaxRateAction
163
     */
164 1
    public function setLineItemTaxRate()
165
    {
166 1
        return CartSetLineItemTaxRateAction::of();
167
    }
168
169
    /**
170
     * @return CartSetShippingMethodTaxRateAction
171
     */
172 1
    public function setShippingMethodTaxRate()
173
    {
174 1
        return CartSetShippingMethodTaxRateAction::of();
175
    }
176
177
    /**
178
     * @return CartAddCustomLineItemAction
179
     */
180 1
    public function addCustomLineItem()
181
    {
182 1
        return CartAddCustomLineItemAction::of();
183
    }
184
185
    /**
186
     * @return CartChangeTaxModeAction
187
     */
188 1
    public function changeTaxMode()
189
    {
190 1
        return CartChangeTaxModeAction::of();
191
    }
192
193
    /**
194
     * @return CartSetCustomLineItemTaxRateAction
195
     */
196 1
    public function setCustomLineItemTaxRate()
197
    {
198 1
        return CartSetCustomLineItemTaxRateAction::of();
199
    }
200
201
    /**
202
     * @return CartSetLineItemTotalPriceAction
203
     */
204 1
    public function setLineItemTotalPrice()
205
    {
206 1
        return CartSetLineItemTotalPriceAction::of();
207
    }
208
209
    /**
210
     * @return CartSetCartTotalTaxAction
211
     */
212 1
    public function setCartTotalTax()
213
    {
214 1
        return CartSetCartTotalTaxAction::of();
215
    }
216
217
    /**
218
     * @return CartChangeLineItemQuantityAction
219
     */
220 1
    public function changeLineItemQuantity()
221
    {
222 1
        return CartChangeLineItemQuantityAction::of();
223
    }
224
225
    /**
226
     * @return CartRecalculateAction
227
     */
228 1
    public function recalculate()
229
    {
230 1
        return CartRecalculateAction::of();
231
    }
232
233
    /**
234
     * @return CartSetCustomerGroupAction
235
     */
236 1
    public function setCustomerGroup()
237
    {
238 1
        return CartSetCustomerGroupAction::of();
239
    }
240
241
    /**
242
     * @return CartSetBillingAddressAction
243
     */
244 1
    public function setBillingAddress()
245
    {
246 1
        return CartSetBillingAddressAction::of();
247
    }
248
249
    /**
250
     * @return CartSetAnonymousIdAction
251
     */
252 1
    public function setAnonymousId()
253
    {
254 1
        return CartSetAnonymousIdAction::of();
255
    }
256
257
    /**
258
     * @return CartSetShippingMethodAction
259
     */
260 1
    public function setShippingMethod()
261
    {
262 1
        return CartSetShippingMethodAction::of();
263
    }
264
265
    /**
266
     * @return CartSetLineItemCustomTypeAction
267
     */
268 1
    public function setLineItemCustomType()
269
    {
270 1
        return CartSetLineItemCustomTypeAction::of();
271
    }
272
273
    /**
274
     * @return CartAddLineItemAction
275
     */
276 1
    public function addLineItem()
277
    {
278 1
        return CartAddLineItemAction::of();
279
    }
280
281
    /**
282
     * @return CartSetCustomerIdAction
283
     */
284 1
    public function setCustomerId()
285
    {
286 1
        return CartSetCustomerIdAction::of();
287
    }
288
289
    /**
290
     * @return CartSetCustomLineItemTaxAmountAction
291
     */
292 1
    public function setCustomLineItemTaxAmount()
293
    {
294 1
        return CartSetCustomLineItemTaxAmountAction::of();
295
    }
296
297
    /**
298
     * @return CartAddShoppingListAction
299
     */
300 1
    public function addShoppingList()
301
    {
302 1
        return CartAddShoppingListAction::of();
303
    }
304
305
    /**
306
     * @return CartAddDiscountCodeAction
307
     */
308 1
    public function addDiscountCode()
309
    {
310 1
        return CartAddDiscountCodeAction::of();
311
    }
312
313
    /**
314
     * @return CartChangeCustomLineItemQuantityAction
315
     */
316 1
    public function changeCustomLineItemQuantity()
317
    {
318 1
        return CartChangeCustomLineItemQuantityAction::of();
319
    }
320
321
    /**
322
     * @return CartSetShippingRateInputAction
323
     */
324 1
    public function setShippingRateInput()
325
    {
326 1
        return CartSetShippingRateInputAction::of();
327
    }
328
329
    /**
330
     * @return CartSetCountryAction
331
     */
332 1
    public function setCountry()
333
    {
334 1
        return CartSetCountryAction::of();
335
    }
336
337
    /**
338
     * @return CartChangeTaxRoundingModeAction
339
     */
340 1
    public function changeTaxRoundingMode()
341
    {
342 1
        return CartChangeTaxRoundingModeAction::of();
343
    }
344
345
    /**
346
     * @return CartRemovePaymentAction
347
     */
348 1
    public function removePayment()
349
    {
350 1
        return CartRemovePaymentAction::of();
351
    }
352
353
    /**
354
     * @return CartSetShippingMethodTaxAmountAction
355
     */
356 1
    public function setShippingMethodTaxAmount()
357
    {
358 1
        return CartSetShippingMethodTaxAmountAction::of();
359
    }
360
361
    /**
362
     * @return CartChangeTaxCalculationModeAction
363
     */
364 1
    public function changeTaxCalculationMode()
365
    {
366 1
        return CartChangeTaxCalculationModeAction::of();
367
    }
368
369
    /**
370
     * @return CartSetCustomLineItemCustomTypeAction
371
     */
372 1
    public function setCustomLineItemCustomType()
373
    {
374 1
        return CartSetCustomLineItemCustomTypeAction::of();
375
    }
376
}
377