Phalcon\Db\Adapter\MongoDB\Operation\Count::__construct PHP Method

__construct() public method

Supported options: * hint (string|document): The index to use. If a document, it will be interpretted as an index specification and a name will be generated. * limit (integer): The maximum number of documents to count. * maxTimeMS (integer): The maximum amount of time to allow the query to run. * readConcern (MongoDB\Driver\ReadConcern): Read concern. For servers < 3.2, this option is ignored as read concern is not available. * readPreference (MongoDB\Driver\ReadPreference): Read preference. * skip (integer): The number of documents to skip before returning the documents.
public __construct ( string $databaseName, string $collectionName, array | object $filter = [], array $options = [] )
$databaseName string Database name
$collectionName string Collection name
$filter array | object Query by which to filter documents
$options array Command options
    public function __construct($databaseName, $collectionName, $filter = [], array $options = [])
    {
        if (!is_array($filter) && !is_object($filter)) {
            throw InvalidArgumentException::invalidType('$filter', $filter, 'array or object');
        }
        if (isset($options['hint'])) {
            if (is_array($options['hint']) || is_object($options['hint'])) {
                $options['hint'] = Functions::generateIndexName($options['hint']);
            }
            if (!is_string($options['hint'])) {
                throw InvalidArgumentException::invalidType('"hint" option', $options['hint'], 'string or array or object');
            }
        }
        if (isset($options['limit']) && !is_integer($options['limit'])) {
            throw InvalidArgumentException::invalidType('"limit" option', $options['limit'], 'integer');
        }
        if (isset($options['maxTimeMS']) && !is_integer($options['maxTimeMS'])) {
            throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');
        }
        if (isset($options['readConcern']) && !$options['readConcern'] instanceof ReadConcern) {
            throw InvalidArgumentException::invalidType('"readConcern" option', $options['readConcern'], 'MongoDB\\Driver\\ReadConcern');
        }
        if (isset($options['readPreference']) && !$options['readPreference'] instanceof ReadPreference) {
            throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\\Driver\\ReadPreference');
        }
        if (isset($options['skip']) && !is_integer($options['skip'])) {
            throw InvalidArgumentException::invalidType('"skip" option', $options['skip'], 'integer');
        }
        $this->databaseName = (string) $databaseName;
        $this->collectionName = (string) $collectionName;
        $this->filter = $filter;
        $this->options = $options;
    }