private function createCommandDocument(Server $server)
    {
        $cmd = ['findAndModify' => $this->collectionName];

        if ($this->options['remove']) {
            $cmd['remove'] = true;
        } else {
            $cmd['new'] = $this->options['new'];
            $cmd['upsert'] = $this->options['upsert'];
        }

        foreach (['collation', 'fields', 'query', 'sort', 'update'] as $option) {
            if (isset($this->options[$option])) {
                $cmd[$option] = (object) $this->options[$option];
            }
        }

        if (isset($this->options['arrayFilters'])) {
            $cmd['arrayFilters'] = $this->options['arrayFilters'];
        }

        if (isset($this->options['maxTimeMS'])) {
            $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
        }

        if (
            ! empty($this->options['bypassDocumentValidation']) &&
            \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)
        ) {
            $cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
        }

        return $cmd;
    }
private function createCommandDocument(Server $server)
    {
        $cmd = ['findAndModify' => $this->collectionName];

        if ($this->options['remove']) {
            $cmd['remove'] = true;
        } else {
            $cmd['new'] = $this->options['new'];
            $cmd['upsert'] = $this->options['upsert'];
        }

        foreach (['collation', 'fields', 'query', 'sort', 'update'] as $option) {
            if (isset($this->options[$option])) {
                $cmd[$option] = (object) $this->options[$option];
            }
        }

        if (isset($this->options['arrayFilters'])) {
            $cmd['arrayFilters'] = $this->options['arrayFilters'];
        }

        if (isset($this->options['maxTimeMS'])) {
            $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
        }

        if (
            ! empty($this->options['bypassDocumentValidation']) &&
            \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)
        ) {
            $cmd['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
        }

        return $cmd;
    }
private function createCommandDocument ( Server $ server ) { $ cmd = [ 'findAndModify' => $ this -> collectionName ] ; if ( $ this -> options [ 'remove' ] ) { $ cmd [ 'remove' ] = true ; } else { $ cmd [ 'new' ] = $ this -> options [ 'new' ] ; $ cmd [ 'upsert' ] = $ this -> options [ 'upsert' ] ; } foreach ( [ 'collation' , 'fields' , 'query' , 'sort' , 'update' ] as $ option ) { if ( isset ( $ this -> options [ $ option ] ) ) { $ cmd [ $ option ] = ( object ) $ this -> options [ $ option ] ; } } if ( isset ( $ this -> options [ 'arrayFilters' ] ) ) { $ cmd [ 'arrayFilters' ] = $ this -> options [ 'arrayFilters' ] ; } if ( isset ( $ this -> options [ 'maxTimeMS' ] ) ) { $ cmd [ 'maxTimeMS' ] = $ this -> options [ 'maxTimeMS' ] ; } if ( ! empty ( $ this -> options [ 'bypassDocumentValidation' ] ) && \ MongoDB \ server_supports_feature ( $ server , self :: $ wireVersionForDocumentLevelValidation ) ) { $ cmd [ 'bypassDocumentValidation' ] = $ this -> options [ 'bypassDocumentValidation' ] ; } return $ cmd ; }
Create the findAndModify command document.

@param Server $server
@return array
Create the findAndModify command document .