commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
GraphQLRequestBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
16 use stdClass;
17 
21 final class GraphQLRequestBuilder implements Builder
22 {
27  private $query;
28 
33  private $operationName;
34 
39  private $variables;
40 
45  public function getQuery()
46  {
47  return $this->query;
48  }
49 
54  public function getOperationName()
55  {
56  return $this->operationName;
57  }
58 
63  public function getVariables()
64  {
65  return $this->variables instanceof GraphQLVariablesMapBuilder ? $this->variables->build() : $this->variables;
66  }
67 
72  public function withQuery(?string $query)
73  {
74  $this->query = $query;
75 
76  return $this;
77  }
78 
83  public function withOperationName(?string $operationName)
84  {
85  $this->operationName = $operationName;
86 
87  return $this;
88  }
89 
94  public function withVariables(?GraphQLVariablesMap $variables)
95  {
96  $this->variables = $variables;
97 
98  return $this;
99  }
100 
106  {
107  $this->variables = $variables;
108 
109  return $this;
110  }
111 
112  public function build(): GraphQLRequest
113  {
114  return new GraphQLRequestModel(
115  $this->query,
116  $this->operationName,
117  $this->variables instanceof GraphQLVariablesMapBuilder ? $this->variables->build() : $this->variables
118  );
119  }
120 
121  public static function of(): GraphQLRequestBuilder
122  {
123  return new self();
124  }
125 }
withVariablesBuilder(?GraphQLVariablesMapBuilder $variables)