originalInput = $params; $params += [ 'query' => null, 'queryid' => null, 'documentid' => null, // alias to queryid 'operation' => null, 'variables' => null ]; if (is_string($params['variables'])) { $tmp = json_decode($params['variables'], true); if (!json_last_error()) { $params['variables'] = $tmp; } } $instance->query = $params['query']; $instance->queryId = $params['queryid'] ?: $params['documentid']; $instance->operation = $params['operation']; $instance->variables = $params['variables']; $instance->readOnly = (bool) $readonly; return $instance; } /** * @param string $key * @return mixed */ public function getOriginalInput($key) { return isset($this->originalInput[$key]) ? $this->originalInput[$key] : null; } /** * @return bool */ public function isReadOnly() { return $this->readOnly; } }