1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Project; |
7
|
|
|
|
8
|
|
|
use Psr\Http\Message\ResponseInterface; |
9
|
|
|
use Commercetools\Core\Client\HttpMethod; |
10
|
|
|
use Commercetools\Core\Client\HttpRequest; |
11
|
|
|
use Commercetools\Core\Client\JsonEndpoint; |
12
|
|
|
use Commercetools\Core\Model\Common\Context; |
13
|
|
|
use Commercetools\Core\Request\AbstractApiRequest; |
14
|
|
|
use Commercetools\Core\Response\ResourceResponse; |
15
|
|
|
use Commercetools\Core\Model\Project\Project; |
16
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
17
|
|
|
use Commercetools\Core\Model\MapperInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @package Commercetools\Core\Request\Project |
21
|
|
|
* @link https://dev.commercetools.com/http-api-projects-project.html#get-project |
22
|
|
|
* @method Project mapResponse(ApiResponseInterface $response) |
23
|
|
|
* @method Project mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null) |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
class ProjectGetRequest extends AbstractApiRequest |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
protected $resultClass = Project::class; |
28
|
|
|
|
29
|
9 |
|
public function __construct(Context $context = null) |
30
|
|
|
{ |
31
|
9 |
|
parent::__construct(new JsonEndpoint(''), $context); |
32
|
9 |
|
} |
33
|
|
|
/** |
34
|
|
|
* @param ResponseInterface $response |
35
|
|
|
* @return ResourceResponse |
36
|
|
|
* @internal |
37
|
|
|
*/ |
38
|
8 |
|
public function buildResponse(ResponseInterface $response) |
39
|
|
|
{ |
40
|
8 |
|
return new ResourceResponse($response, $this, $this->getContext()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return HttpRequest |
45
|
|
|
* @internal |
46
|
|
|
*/ |
47
|
8 |
|
public function httpRequest() |
48
|
|
|
{ |
49
|
8 |
|
return new HttpRequest(HttpMethod::GET, $this->getPath()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param Context $context |
54
|
|
|
* @return static |
55
|
|
|
*/ |
56
|
9 |
|
public static function of(Context $context = null) |
57
|
|
|
{ |
58
|
9 |
|
return new static($context); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
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.