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
|
|
|
use Commercetools\Core\Model\Common\Money; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @package Commercetools\Core\Request\Carts\Command |
14
|
|
|
* @link https://dev.commercetools.com/http-api-projects-carts.html#change-customlineitem-money |
15
|
|
|
* @method string getAction() |
16
|
|
|
* @method CartChangeCustomLineItemMoneyAction setAction(string $action = null) |
17
|
|
|
* @method string getCustomLineItemId() |
18
|
|
|
* @method CartChangeCustomLineItemMoneyAction setCustomLineItemId(string $customLineItemId = null) |
19
|
|
|
* @method Money getMoney() |
20
|
|
|
* @method CartChangeCustomLineItemMoneyAction setMoney(Money $money = null) |
21
|
|
|
*/ |
22
|
|
View Code Duplication |
class CartChangeCustomLineItemMoneyAction extends AbstractAction |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
public function fieldDefinitions() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
'action' => [static::TYPE => 'string'], |
28
|
|
|
'customLineItemId' => [static::TYPE => 'string'], |
29
|
|
|
'money' => [static::TYPE => '\Commercetools\Core\Model\Common\Money'], |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param array $data |
35
|
|
|
* @param Context|callable $context |
36
|
|
|
*/ |
37
|
|
|
public function __construct(array $data = [], $context = null) |
38
|
|
|
{ |
39
|
|
|
parent::__construct($data, $context); |
40
|
|
|
$this->setAction('changeCustomLineItemMoney'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $customLineItemId |
45
|
|
|
* @param Money $money |
46
|
|
|
* @param Context|callable $context |
47
|
|
|
* @return CartSetLineItemTotalPriceAction |
48
|
|
|
*/ |
49
|
|
|
public static function ofCustomLineItemIdAndMoney($customLineItemId, Money $money, $context = null) |
50
|
|
|
{ |
51
|
|
|
return static::of($context)->setCustomLineItemId($customLineItemId)->setMoney($money); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
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.