Passed
Push — develop ( 5aeb9c...e255e4 )
by Jens
10:37 queued 13s
created

ApiClientDeleteRequest::ofId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 */
4
5
namespace Commercetools\Core\Request\ApiClients;
6
7
use Commercetools\Core\Client\HttpMethod;
8
use Commercetools\Core\Client\HttpRequest;
9
use Commercetools\Core\Model\ApiClient\ApiClient;
10
use Commercetools\Core\Model\Common\Context;
11
use Commercetools\Core\Request\AbstractApiRequest;
12
use Commercetools\Core\Response\ResourceResponse;
13
use Psr\Http\Message\ResponseInterface;
14
use Commercetools\Core\Response\ApiResponseInterface;
15
use Commercetools\Core\Model\MapperInterface;
16
17
/**
18
 * @package Commercetools\Core\Request\ApiClients
19
 * @method ApiClient mapResponse(ApiResponseInterface $response)
20
 * @method ApiClient mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
21
 */
22
class ApiClientDeleteRequest extends AbstractApiRequest
23
{
24
    protected $resultClass = ApiClient::class;
25
26
27
    /**
28
     * @var string
29
     */
30
    protected $id;
31
32
    /**
33
     * @param string $id
34
     * @param Context $context
35
     */
36
    public function __construct($id, Context $context = null)
37
    {
38
        parent::__construct(ApiClientsEndpoint::endpoint(), $context);
39
        $this->setId($id);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getId()
46
    {
47
        return $this->id;
48
    }
49
50
    /**
51
     * @param $id
52
     * @return $this
53
     */
54
    public function setId($id)
55
    {
56
        $this->id = $id;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @return string
63
     * @internal
64
     */
65
    protected function getPath()
66
    {
67
        return (string)$this->getEndpoint() . '/' . $this->getId();
68
    }
69
70
    /**
71
     * @return HttpRequest
72
     * @internal
73
     */
74
    public function httpRequest()
75
    {
76
        return new HttpRequest(HttpMethod::DELETE, $this->getPath());
77
    }
78
79
    /**
80
     * @param ResponseInterface $response
81
     * @return ResourceResponse
82
     * @internal
83
     */
84
    public function buildResponse(ResponseInterface $response)
85
    {
86
        return new ResourceResponse($response, $this, $this->getContext());
87
    }
88
89
    /**
90
     * @param string $id
91
     * @param Context $context
92
     * @return static
93
     */
94
    public static function ofId($id, Context $context = null)
95
    {
96
        return new static($id, $context);
97
    }
98
}
99