Passed
Push — develop ( 3a55d2...1bb7ea )
by Jens
11:37
created

MeGetRequest::httpRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[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
use Commercetools\Core\Model\MapperInterface;
17
18
/**
19
 * @package Commercetools\Core\Request\Me
20
 * @link https://docs.commercetools.com/http-api-projects-me-profile.html#get-customer
21
 * @method Customer mapResponse(ApiResponseInterface $response)
22
 * @method Customer mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
23
 */
24
class MeGetRequest extends AbstractApiRequest
25
{
26
    protected $resultClass = Customer::class;
27
28
    /**
29
     * @param Context $context
30
     */
31 4
    public function __construct(Context $context = null)
32
    {
33 4
        parent::__construct(MeEndpoint::endpoint(), $context);
34 4
    }
35
36
    /**
37
     * @param Context $context
38
     * @return static
39
     */
40 4
    public static function of(Context $context = null)
41
    {
42 4
        return new static($context);
43
    }
44
45
    /**
46
     * @return HttpRequest
47
     * @internal
48
     */
49 4
    public function httpRequest()
50
    {
51 4
        return new HttpRequest(HttpMethod::GET, $this->getPath());
52
    }
53
54
    /**
55
     * @param ResponseInterface $response
56
     * @return ResourceResponse
57
     * @internal
58
     */
59 3
    public function buildResponse(ResponseInterface $response)
60
    {
61 3
        return new ResourceResponse($response, $this, $this->getContext());
62
    }
63
}
64