Passed
Push — develop ( f7291a...3ba959 )
by Jens
09:14
created

ShippingMethodUpdateByKeyRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A ofKeyAndVersion() 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\ShippingMethods;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\ShippingMethod\ShippingMethod;
10
use Commercetools\Core\Request\AbstractUpdateByKeyRequest;
11
use Commercetools\Core\Response\ApiResponseInterface;
12
use Commercetools\Core\Model\MapperInterface;
13
14
/**
15
 * @package Commercetools\Core\Request\ShippingMethods
16
 * @link http://dev.commercetools.com/http-api-projects-shippingMethods.html#update-shippingmethod-by-key
17
 * @method ShippingMethod mapResponse(ApiResponseInterface $response)
18
 * @method ShippingMethod mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
19
 */
20 View Code Duplication
class ShippingMethodUpdateByKeyRequest extends AbstractUpdateByKeyRequest
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 = ShippingMethod::class;
23
24
    /**
25
     * @param string $key
26
     * @param string $version
27
     * @param array $actions
28
     * @param Context $context
29
     */
30 1
    public function __construct($key, $version, array $actions = [], Context $context = null)
31
    {
32 1
        parent::__construct(ShippingMethodsEndpoint::endpoint(), $key, $version, $actions, $context);
33 1
    }
34
35
    /**
36
     * @param string $key
37
     * @param int $version
38
     * @param Context $context
39
     * @return static
40
     */
41 1
    public static function ofKeyAndVersion($key, $version, Context $context = null)
42
    {
43 1
        return new static($key, $version, [], $context);
44
    }
45
}
46