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

OrderDeleteByOrderNumberRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
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 51
loc 51
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\AbstractDeleteRequest;
10
use Commercetools\Core\Response\ApiResponseInterface;
11
use Commercetools\Core\Model\Order\Order;
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#delete-order-by-ordernumber
17
 * @method Order mapResponse(ApiResponseInterface $response)
18
 * @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
19
 */
20 View Code Duplication
class OrderDeleteByOrderNumberRequest extends AbstractDeleteRequest
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 $id
26
     * @param int $version
27
     * @param Context $context
28
     */
29 1
    public function __construct($id, $version, Context $context = null)
30
    {
31 1
        parent::__construct(OrdersEndpoint::endpoint(), $id, $version, $context);
32 1
    }
33
34
    /**
35
     * @param string $orderNumber
36
     * @param int $version
37
     * @param Context $context
38
     * @return static
39
     */
40 1
    public static function ofOrderNumberAndVersion($orderNumber, $version, Context $context = null)
41
    {
42 1
        return new static($orderNumber, $version, $context);
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getOrderNumber()
49
    {
50
        return $this->getId();
51
    }
52
53
    /**
54
     * @param string $orderNumber
55
     * @return $this
56
     */
57
    public function setOrderNumber($orderNumber)
58
    {
59
        return $this->setId($orderNumber);
60
    }
61
62
    /**
63
     * @return string
64
     * @internal
65
     */
66 1
    protected function getPath()
67
    {
68 1
        return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString();
69
    }
70
}
71