1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Carts\Command; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Request\AbstractAction; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @package Commercetools\Core\Request\Carts\Command |
13
|
|
|
* @link https://dev.commercetools.com/http-api-projects-carts.html#change-customlineitem-quantity |
14
|
|
|
* @method string getAction() |
15
|
|
|
* @method CartChangeCustomLineItemQuantityAction setAction(string $action = null) |
16
|
|
|
* @method int getQuantity() |
17
|
|
|
* @method CartChangeCustomLineItemQuantityAction setQuantity(int $quantity = null) |
18
|
|
|
* @method string getCustomLineItemId() |
19
|
|
|
* @method CartChangeCustomLineItemQuantityAction setCustomLineItemId(string $customLineItemId = null) |
20
|
|
|
*/ |
21
|
|
View Code Duplication |
class CartChangeCustomLineItemQuantityAction extends AbstractAction |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
public function fieldDefinitions() |
24
|
|
|
{ |
25
|
|
|
return [ |
26
|
|
|
'action' => [static::TYPE => 'string'], |
27
|
|
|
'customLineItemId' => [static::TYPE => 'string'], |
28
|
|
|
'quantity' => [static::TYPE => 'int'], |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param array $data |
34
|
|
|
* @param Context|callable $context |
35
|
|
|
*/ |
36
|
|
|
public function __construct(array $data = [], $context = null) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($data, $context); |
39
|
|
|
$this->setAction('changeCustomLineItemQuantity'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $customLineItemId |
44
|
|
|
* @param int $quantity |
45
|
|
|
* @param Context|callable $context |
46
|
|
|
* @return CartChangeCustomLineItemQuantityAction |
47
|
|
|
*/ |
48
|
|
|
public static function ofCustomLineItemIdAndQuantity($customLineItemId, $quantity, $context = null) |
49
|
|
|
{ |
50
|
|
|
return static::of($context)->setCustomLineItemId($customLineItemId)->setQuantity($quantity); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.