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-customlineitem-customfield |
14
|
|
|
* @method string getAction() |
15
|
|
|
* @method CartSetCustomLineItemCustomFieldAction setAction(string $action = null) |
16
|
|
|
* @method string getName() |
17
|
|
|
* @method CartSetCustomLineItemCustomFieldAction setName(string $name = null) |
18
|
|
|
* @method string getCustomLineItemId() |
19
|
|
|
* @method CartSetCustomLineItemCustomFieldAction setCustomLineItemId(string $customLineItemId = null) |
20
|
|
|
* @method mixed getValue() |
21
|
|
|
* @method CartSetCustomLineItemCustomFieldAction setValue($value = null) |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
class CartSetCustomLineItemCustomFieldAction 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 |
|
'customLineItemId' => [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('setCustomLineItemCustomField'); |
43
|
2 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $customLineItemId |
47
|
|
|
* @param string $name |
48
|
|
|
* @param Context|callable $context |
49
|
|
|
* @return static |
50
|
|
|
*/ |
51
|
|
|
public static function ofCustomLineItemIdAndName($customLineItemId, $name, $context = null) |
52
|
|
|
{ |
53
|
|
|
return static::of($context)->setCustomLineItemId($customLineItemId)->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.