private function createCommand(Server $server)
{
$cmd = ['count' => $this->collectionName];
if (!empty($this->filter)) {
$cmd['query'] = (object) $this->filter;
}
foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
if (isset($this->options[$option])) {
$cmd[$option] = $this->options[$option];
}
}
if (isset($this->options['readConcern']) && Functions::serverSupportsFeature($server, self::$wireVersionForReadConcern)) {
$cmd['readConcern'] = Functions::readConcernAsDocument($this->options['readConcern']);
}
return new Command($cmd);
}