Passed
Push — master ( 429b06...f0c7c5 )
by Rafael
08:46
created

GraphiQLRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
dl 0
loc 63
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 3 1
A addHeader() 0 3 1
A addParameter() 0 3 1
A __construct() 0 5 1
A getHeaders() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\GraphiQL;
12
13
/**
14
 * GraphiQLRequest
15
 */
16
class GraphiQLRequest
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $url;
22
23
    /**
24
     * @var array
25
     */
26
    protected $params = [];
27
28
    /**
29
     * @var array
30
     */
31
    protected $headers = [];
32
33
    /**
34
     * GraphiQLRequest constructor.
35
     *
36
     * @param string $url
37
     * @param array  $params
38
     * @param array  $headers
39
     */
40
    public function __construct(string $url, array $params = [], array $headers = [])
41
    {
42
        $this->url = $url;
43
        $this->params = $params;
44
        $this->headers = $headers;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getUrl(): string
51
    {
52
        return $this->url.'?'.http_build_query($this->params);
53
    }
54
55
    /**
56
     * @param string $name
57
     * @param mixed  $value
58
     */
59
    public function addParameter(string $name, $value)
60
    {
61
        $this->params[$name] = $value;
62
    }
63
64
    /**
65
     * @param string $name
66
     * @param mixed  $value
67
     */
68
    public function addHeader(string $name, $value)
69
    {
70
        $this->headers[$name] = $value;
71
    }
72
73
    /**
74
     * @return array
75
     */
76
    public function getHeaders(): array
77
    {
78
        return $this->headers;
79
    }
80
}
81