1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Request\Payments\Command; |
8
|
|
|
|
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Request\AbstractAction; |
11
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package Commercetools\Core\Request\Payments\Command |
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-payments.html#change-transaction-timestamp |
16
|
|
|
* @method string getAction() |
17
|
|
|
* @method PaymentChangeTransactionTimestampAction setAction(string $action = null) |
18
|
|
|
* @method string getTransactionId() |
19
|
|
|
* @method PaymentChangeTransactionTimestampAction setTransactionId(string $transactionId = null) |
20
|
|
|
* @method DateTimeDecorator getTimestamp() |
21
|
|
|
* @method PaymentChangeTransactionTimestampAction setTimestamp(\DateTime $timestamp = null) |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
class PaymentChangeTransactionTimestampAction extends AbstractAction |
|
|
|
|
24
|
|
|
{ |
25
|
4 |
|
public function fieldDefinitions() |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
4 |
|
'action' => [static::TYPE => 'string'], |
29
|
4 |
|
'transactionId' => [static::TYPE => 'string'], |
30
|
|
|
'timestamp' => [ |
31
|
4 |
|
static::TYPE => '\DateTime', |
32
|
4 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' |
33
|
|
|
], |
34
|
|
|
]; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param array $data |
39
|
|
|
* @param Context|callable $context |
40
|
|
|
*/ |
41
|
2 |
|
public function __construct(array $data = [], $context = null) |
42
|
|
|
{ |
43
|
2 |
|
parent::__construct($data, $context); |
44
|
2 |
|
$this->setAction('changeTransactionTimestamp'); |
45
|
2 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $transactionId |
49
|
|
|
* @param \DateTime $timestamp |
50
|
|
|
* @param Context|callable $context |
51
|
|
|
* @return PaymentAddTransactionAction |
52
|
|
|
*/ |
53
|
1 |
|
public static function ofTransactionIdAndTimestamp($transactionId, \DateTime $timestamp, $context = null) |
54
|
|
|
{ |
55
|
1 |
|
return static::of($context)->setTransactionId($transactionId)->setTimestamp($timestamp); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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.