Passed
Push — develop ( bd744c...8ef8de )
by
unknown
09:01
created

OrderSetDeliveryAddressAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 31
loc 31
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 8 8 1
A __construct() 5 5 1
A ofDeliveryId() 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 @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\Orders\Command;
7
8
use Commercetools\Core\Model\Common\Address;
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Model\Order\DeliveryItemCollection;
11
use Commercetools\Core\Model\Order\ParcelCollection;
12
use Commercetools\Core\Model\Order\ParcelMeasurements;
13
use Commercetools\Core\Model\Order\TrackingData;
14
use Commercetools\Core\Request\AbstractAction;
15
16
/**
17
 * @package Commercetools\Core\Request\Orders\Command
18
 * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-address
19
 * @method string getAction()
20
 * @method OrderSetDeliveryAddressAction setAction(string $action = null)
21
 * @method string getDeliveryId()
22
 * @method OrderSetDeliveryAddressAction setDeliveryId(string $deliveryId = null)
23
 * @method Address getAddress()
24
 * @method OrderSetDeliveryAddressAction setAddress(Address $address = null)
25
 */
26 View Code Duplication
class OrderSetDeliveryAddressAction 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...
27
{
28 1
    public function fieldDefinitions()
29
    {
30
        return [
31 1
            'action' => [static::TYPE => 'string'],
32 1
            'deliveryId' => [static::TYPE => 'string'],
33 1
            'address' => [static::TYPE => Address::class],
34
        ];
35
    }
36
37
    /**
38
     * @param array $data
39
     * @param Context|callable $context
40
     */
41 1
    public function __construct(array $data = [], $context = null)
42
    {
43 1
        parent::__construct($data, $context);
44 1
        $this->setAction('setDeliveryAddress');
45 1
    }
46
47
    /**
48
     * @param string $deliveryId
49
     * @param Context|callable $context
50
     * @return OrderSetDeliveryAddressAction
51
     */
52 1
    public static function ofDeliveryId($deliveryId, $context = null)
53
    {
54 1
        return static::of($context)->setDeliveryId($deliveryId);
55
    }
56
}
57