commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
GraphQLRequestModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
20 final class GraphQLRequestModel extends JsonObjectModel implements GraphQLRequest
21 {
26  protected $query;
27 
32  protected $operationName;
33 
38  protected $variables;
39 
40 
44  public function __construct(
45  ?string $query = null,
46  ?string $operationName = null,
48  ) {
49  $this->query = $query;
50  $this->operationName = $operationName;
51  $this->variables = $variables;
52  }
53 
58  public function getQuery()
59  {
60  if (is_null($this->query)) {
62  $data = $this->raw(self::FIELD_QUERY);
63  if (is_null($data)) {
64  return null;
65  }
66  $this->query = (string) $data;
67  }
68 
69  return $this->query;
70  }
71 
76  public function getOperationName()
77  {
78  if (is_null($this->operationName)) {
80  $data = $this->raw(self::FIELD_OPERATION_NAME);
81  if (is_null($data)) {
82  return null;
83  }
84  $this->operationName = (string) $data;
85  }
86 
87  return $this->operationName;
88  }
89 
94  public function getVariables()
95  {
96  if (is_null($this->variables)) {
98  $data = $this->raw(self::FIELD_VARIABLES);
99  if (is_null($data)) {
100  return null;
101  }
102 
103  $this->variables = GraphQLVariablesMapModel::of($data);
104  }
105 
106  return $this->variables;
107  }
108 
109 
113  public function setQuery(?string $query): void
114  {
115  $this->query = $query;
116  }
117 
121  public function setOperationName(?string $operationName): void
122  {
123  $this->operationName = $operationName;
124  }
125 
130  {
131  $this->variables = $variables;
132  }
133 }
__construct(?string $query=null, ?string $operationName=null, ?GraphQLVariablesMap $variables=null)