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

MeSignupRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 37
loc 37
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A ofCustomer() 4 4 1
A httpRequest() 8 8 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\CustomerSigninResult;
12
use Commercetools\Core\Model\Customer\MyCustomerDraft;
13
use Commercetools\Core\Request\AbstractCreateRequest;
14
use Commercetools\Core\Response\ApiResponseInterface;
15
16
/**
17
 * @package Commercetools\Core\Request\Me
18
 * @method CustomerSigninResult mapResponse(ApiResponseInterface $response)
19
 */
20 View Code Duplication
class MeSignupRequest extends AbstractCreateRequest
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 = '\Commercetools\Core\Model\Customer\CustomerSigninResult';
23
24
    /**
25
     * MeGetRequest constructor.
26
     * @param MyCustomerDraft $customer
27
     * @param Context $context
28
     */
29
    public function __construct(MyCustomerDraft $customer, Context $context = null)
30
    {
31
        parent::__construct(MeEndpoint::endpoint(), $customer, $context);
32
    }
33
34
    /**
35
     * @param MyCustomerDraft $customer
36
     * @param Context $context
37
     * @return static
38
     */
39
    public static function ofCustomer(MyCustomerDraft $customer, Context $context = null)
40
    {
41
        return new static($customer, $context);
42
    }
43
44
    /**
45
     * @return HttpRequest
46
     * @internal
47
     */
48
    public function httpRequest()
49
    {
50
        return new HttpRequest(
51
            HttpMethod::POST,
52
            (string)$this->getEndpoint() . '/signup' . $this->getParamString(),
53
            $this->getObject()
54
        );
55
    }
56
}
57