Completed
Push — develop ( e77623...3cc0f7 )
by Jens
09:01
created

MeGetRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 4
dl 40
loc 40
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A of() 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\Model\Customer\Customer;
12
use Commercetools\Core\Request\AbstractApiRequest;
13
use Commercetools\Core\Response\ApiResponseInterface;
14
use Commercetools\Core\Response\ResourceResponse;
15
use Psr\Http\Message\ResponseInterface;
16
17
/**
18
 * @package Commercetools\Core\Request\Me
19
 * @method Customer mapResponse(ApiResponseInterface $response)
20
 */
21 View Code Duplication
class MeGetRequest 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...
22
{
23
    protected $resultClass = '\Commercetools\Core\Model\Customer\Customer';
24
25
    /**
26
     * @param Context $context
27
     */
28 4
    public function __construct(Context $context = null)
29
    {
30 4
        parent::__construct(MeEndpoint::endpoint(), $context);
31 4
    }
32
33
    /**
34
     * @param Context $context
35
     * @return static
36
     */
37 4
    public static function of(Context $context = null)
38
    {
39 4
        return new static($context);
40
    }
41
42
    /**
43
     * @return HttpRequest
44
     * @internal
45
     */
46 4
    public function httpRequest()
47
    {
48 4
        return new HttpRequest(HttpMethod::GET, $this->getPath());
49
    }
50
51
    /**
52
     * @param ResponseInterface $response
53
     * @return ResourceResponse
54
     * @internal
55
     */
56 3
    public function buildResponse(ResponseInterface $response)
57
    {
58 3
        return new ResourceResponse($response, $this, $this->getContext());
59
    }
60
}
61