Skip to content

Commit 6fc45f6

Browse files
committed
addArguments() && addPrefix() to last item in selectionSet
1 parent 06b91cd commit 6fc45f6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/QueryBuilder/AbstractQueryBuilder.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,37 @@ protected function setVariable(string $name, string $type, bool $isRequired = fa
119119

120120
return $this;
121121
}
122+
123+
/**
124+
* @param array|null $args
125+
* @return $this
126+
*/
127+
public function addArguments(array $args = null) {
128+
129+
if (is_array($args) && count($this->selectionSet)) {
130+
131+
$params = '';
132+
foreach ($args as $k => $v) {
133+
$params.= " $k : \"$v\" ";
134+
}
135+
136+
$this->selectionSet[count($this->selectionSet) - 1] = $this->selectionSet[count($this->selectionSet) - 1] . " ($params)";
137+
}
138+
139+
return $this;
140+
}
141+
142+
/**
143+
* @param string|null $prefix
144+
* @return $this
145+
*/
146+
public function addPrefix(string $prefix = null) {
147+
148+
if ($prefix && count($this->selectionSet)) {
149+
150+
$this->selectionSet[count($this->selectionSet) - 1] = $prefix . ':' . $this->selectionSet[count($this->selectionSet) - 1];
151+
}
152+
153+
return $this;
154+
}
122155
}

0 commit comments

Comments
 (0)