Completed
Push — develop ( bf5303...e61d29 )
by Jens
09:27
created

MeActiveCartRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 4
dl 49
loc 49
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A of() 4 4 1
A getPath() 4 4 1
A httpRequest() 4 4 1
A buildResponse() 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\Me;
7
8
use Commercetools\Core\Client\HttpMethod;
9
use Commercetools\Core\Client\HttpRequest;
10
use Commercetools\Core\Model\Common\Context;
11
use Commercetools\Core\Request\AbstractApiRequest;
12
use Commercetools\Core\Request\AbstractByIdGetRequest;
13
use Commercetools\Core\Model\Cart\Cart;
14
use Commercetools\Core\Response\ApiResponseInterface;
15
use Commercetools\Core\Response\ResourceResponse;
16
use Psr\Http\Message\ResponseInterface;
17
18
/**
19
 * @package Commercetools\Core\Request\Me
20
 * @link https://dev.commercetools.com/http-api-projects-me-carts.html#get-active-cart
21
 * @method Cart mapResponse(ApiResponseInterface $response)
22
 */
23 View Code Duplication
class MeActiveCartRequest extends AbstractApiRequest
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
    protected $resultClass = '\Commercetools\Core\Model\Cart\Cart';
26
27
    /**
28
     * @param Context $context
29
     */
30
    public function __construct(Context $context = null)
31
    {
32
        parent::__construct(MeEndpoint::endpoint(), $context);
33
    }
34
35
    /**
36
     * @param Context $context
37
     * @return static
38
     */
39
    public static function of(Context $context = null)
40
    {
41
        return new static($context);
42
    }
43
44
    /**
45
     * @return string
46
     * @internal
47
     */
48
    protected function getPath()
49
    {
50
        return (string)$this->getEndpoint() . '/active-cart' . $this->getParamString();
51
    }
52
53
    /**
54
     * @return HttpRequest
55
     * @internal
56
     */
57
    public function httpRequest()
58
    {
59
        return new HttpRequest(HttpMethod::GET, $this->getPath());
60
    }
61
62
    /**
63
     * @param ResponseInterface $response
64
     * @return ResourceResponse
65
     * @internal
66
     */
67
    public function buildResponse(ResponseInterface $response)
68
    {
69
        return new ResourceResponse($response, $this, $this->getContext());
70
    }
71
}
72