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

MeUpdateRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A ofVersion() 0 4 1
A getPath() 0 4 1
A httpRequest() 0 5 1
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\Client\JsonRequest;
11
use Commercetools\Core\Model\Common\Context;
12
use Commercetools\Core\Model\Customer\Customer;
13
use Commercetools\Core\Request\AbstractUpdateRequest;
14
use Commercetools\Core\Response\ApiResponseInterface;
15
16
/**
17
 * @package Commercetools\Core\Request\Me
18
 * @method Customer mapResponse(ApiResponseInterface $response)
19
 */
20
class MeUpdateRequest extends AbstractUpdateRequest
21
{
22
    protected $resultClass = '\Commercetools\Core\Model\Customer\Customer';
23
24
    /**
25
     * @param int $version
26
     * @param Context $context
27
     */
28
    public function __construct($version, Context $context = null)
29
    {
30
        parent::__construct(MeEndpoint::endpoint(), null, $version, $context);
0 ignored issues
show
Documentation introduced by
$context is of type null|object<Commercetool...e\Model\Common\Context>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
    }
32
33
    /**
34
     * @param int $version
35
     * @param Context $context
36
     * @return static
37
     */
38
    public static function ofVersion($version, Context $context = null)
39
    {
40
        return new static($version, $context);
41
    }
42
43
    /**
44
     * @return string
45
     * @internal
46
     */
47
    protected function getPath()
48
    {
49
        return (string)$this->getEndpoint() . $this->getParamString();
50
    }
51
52
    /**
53
     * @return HttpRequest
54
     * @internal
55
     */
56
    public function httpRequest()
57
    {
58
        $payload = [static::VERSION => $this->getVersion(), static::ACTIONS => $this->getActions()];
59
        return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload);
60
    }
61
}
62