private function createQuery()
{
$options = [];
if (!empty($this->options['allowPartialResults'])) {
$options['partial'] = true;
}
if (isset($this->options['cursorType'])) {
if ($this->options['cursorType'] === self::TAILABLE) {
$options['tailable'] = true;
}
if ($this->options['cursorType'] === self::TAILABLE_AWAIT) {
$options['tailable'] = true;
$options['awaitData'] = true;
}
}
foreach (['batchSize', 'limit', 'skip', 'sort', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern'] as $option) {
if (isset($this->options[$option])) {
$options[$option] = $this->options[$option];
}
}
$modifiers = empty($this->options['modifiers']) ? [] : (array) $this->options['modifiers'];
if (isset($this->options['comment'])) {
$modifiers['$comment'] = $this->options['comment'];
}
if (isset($this->options['maxTimeMS'])) {
$modifiers['$maxTimeMS'] = $this->options['maxTimeMS'];
}
if (!empty($modifiers)) {
$options['modifiers'] = $modifiers;
}
return new Query($this->filter, $options);
}