databaseName = (string) $databaseName; $this->collectionName = (string) $collectionName; $this->options = array_intersect_key($options, ['maxTimeMS' => 1, 'readConcern' => 1, 'readPreference' => 1, 'session' => 1]); $this->count = $this->createCount(); } /** * Execute the operation. * * @see Executable::execute() * @param Server $server * @return integer * @throws UnexpectedValueException if the command response was malformed * @throws UnsupportedException if collation or read concern is used and unsupported * @throws DriverRuntimeException for other driver errors (e.g. connection errors) */ public function execute(Server $server) { return $this->count->execute($server); } public function getCommandDocument(Server $server) { return $this->count->getCommandDocument($server); } /** * @return Count */ private function createCount() { return new Count($this->databaseName, $this->collectionName, [], $this->options); } }