|
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\CustomField\Command\SetCustomFieldAction; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @package Commercetools\Core\Request\Carts\Command |
|
13
|
|
|
* @link https://dev.commercetools.com/http-api-projects-carts.html#set-lineitem-customfield |
|
14
|
|
|
* @method string getAction() |
|
15
|
|
|
* @method CartSetLineItemCustomFieldAction setAction(string $action = null) |
|
16
|
|
|
* @method string getName() |
|
17
|
|
|
* @method CartSetLineItemCustomFieldAction setName(string $name = null) |
|
18
|
|
|
* @method string getLineItemId() |
|
19
|
|
|
* @method CartSetLineItemCustomFieldAction setLineItemId(string $lineItemId = null) |
|
20
|
|
|
* @method mixed getValue() |
|
21
|
|
|
* @method CartSetLineItemCustomFieldAction setValue($value = null) |
|
22
|
|
|
*/ |
|
23
|
|
View Code Duplication |
class CartSetLineItemCustomFieldAction extends SetCustomFieldAction |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
2 |
|
public function fieldDefinitions() |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
2 |
|
'action' => [static::TYPE => 'string'], |
|
29
|
2 |
|
'name' => [static::TYPE => 'string'], |
|
30
|
2 |
|
'lineItemId' => [static::TYPE => 'string'], |
|
31
|
2 |
|
'value' => [static::TYPE => null], |
|
32
|
|
|
]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param array $data |
|
37
|
|
|
* @param Context|callable $context |
|
38
|
|
|
*/ |
|
39
|
2 |
|
public function __construct(array $data = [], $context = null) |
|
40
|
|
|
{ |
|
41
|
2 |
|
parent::__construct($data, $context); |
|
42
|
2 |
|
$this->setAction('setLineItemCustomField'); |
|
43
|
2 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $lineItemId |
|
47
|
|
|
* @param string $name |
|
48
|
|
|
* @param Context|callable $context |
|
49
|
|
|
* @return static |
|
50
|
|
|
*/ |
|
51
|
|
|
public static function ofLineItemIdAndName($lineItemId, $name, $context = null) |
|
52
|
|
|
{ |
|
53
|
|
|
return static::of($context)->setLineItemId($lineItemId)->setName($name); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
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.