Completed
Push — develop ( 220c1d...9da6d6 )
by Jens
09:00
created

GraphQLQueryRequest::httpRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
7
namespace Commercetools\Core\Request\GraphQL;
8
9
use Commercetools\Core\Client\HttpMethod;
10
use Commercetools\Core\Client\HttpRequest;
11
use Commercetools\Core\Model\Common\Context;
12
use Commercetools\Core\Request\AbstractApiRequest;
13
use Commercetools\Core\Response\ResourceResponse;
14
use Psr\Http\Message\ResponseInterface;
15
use Commercetools\Core\Model\Common\JsonObject;
16
use Commercetools\Core\Response\ApiResponseInterface;
17
18
/**
19
 * @package Commercetools\Core\Request\GraphQL
20
 *
21
 * @method JsonObject mapResponse(ApiResponseInterface $response)
22
 */
23 View Code Duplication
class GraphQLQueryRequest extends AbstractApiRequest
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...
24
{
25
    /**
26
     * @param Context $context
27
     */
28 1
    public function __construct(Context $context = null)
29
    {
30 1
        parent::__construct(GraphQLEndpoint::endpoint(), $context);
31 1
    }
32
33 1
    public function buildResponse(ResponseInterface $response)
34
    {
35 1
        return new ResourceResponse($response, $this, $this->getContext());
36
    }
37
38 1
    public function httpRequest()
39
    {
40 1
        return new HttpRequest(HttpMethod::GET, $this->getPath());
41
    }
42
43 1
    public function query($query)
44
    {
45 1
        $this->addParam('query', $query);
46 1
    }
47
48 1
    public static function of(Context $context = null)
49
    {
50 1
        return new static($context);
51
    }
52
}
53