Passed
Branch develop (dc1a10)
by Jens
08:20
created

OrderUpdateByOrderNumberRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 52
loc 52
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A ofOrderNumberAndVersion() 4 4 1
A getOrderNumber() 4 4 1
A setOrderNumber() 4 4 1
A getPath() 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
namespace Commercetools\Core\Request\Orders;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Request\AbstractUpdateRequest;
10
use Commercetools\Core\Model\Order\Order;
11
use Commercetools\Core\Response\ApiResponseInterface;
12
use Commercetools\Core\Model\MapperInterface;
13
14
/**
15
 * @package Commercetools\Core\Request\Orders
16
 * @link https://dev.commercetools.com/http-api-projects-orders.html#update-order-by-ordernumber
17
 * @method Order mapResponse(ApiResponseInterface $response)
18
 * @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
19
 */
20 View Code Duplication
class OrderUpdateByOrderNumberRequest extends AbstractUpdateRequest
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...
21
{
22
    protected $resultClass = Order::class;
23
24
    /**
25
     * @param string $orderNumber
26
     * @param string $version
27
     * @param array $actions
28
     * @param Context $context
29
     */
30 1
    public function __construct($orderNumber, $version, array $actions = [], Context $context = null)
31
    {
32 1
        parent::__construct(OrdersEndpoint::endpoint(), $orderNumber, $version, $actions, $context);
33 1
    }
34
35
    /**
36
     * @param string $orderNumber
37
     * @param int $version
38
     * @param Context $context
39
     * @return static
40
     */
41 1
    public static function ofOrderNumberAndVersion($orderNumber, $version, Context $context = null)
42
    {
43 1
        return new static($orderNumber, $version, [], $context);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getOrderNumber()
50
    {
51
        return $this->getId();
52
    }
53
54
    /**
55
     * @param string $orderNumber
56
     * @return $this
57
     */
58
    public function setOrderNumber($orderNumber)
59
    {
60
        return $this->setId($orderNumber);
61
    }
62
63
    /**
64
     * @return string
65
     * @internal
66
     */
67 1
    protected function getPath()
68
    {
69 1
        return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString();
70
    }
71
}
72