Completed
Push — develop ( 58cdba...7f1e46 )
by Jens
08:46
created

PaymentChangeTransactionTimestampAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 35
loc 35
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 11 11 1
A __construct() 5 5 1
A ofTransactionIdAndTimestamp() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
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