public function __construct($databaseName, $command, array $options = [])
{
if (!is_array($command) && !is_object($command)) {
throw InvalidArgumentException::invalidType('$command', $command, 'array or object');
}
if (isset($options['readPreference']) && !$options['readPreference'] instanceof ReadPreference) {
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\\Driver\\ReadPreference');
}
if (isset($options['typeMap']) && !is_array($options['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
}
$this->databaseName = (string) $databaseName;
$this->command = $command instanceof Command ? $command : new Command($command);
$this->options = $options;
}