/** * @param MongoDbCriteria|array|null $query * @return int */ public function count($query = null) { if ($query instanceof MongoDbCriteria) { return $this->getCollection()->count($query->getConditions()); } else { if (is_array($query) && sizeof($query) > 0) { return $this->getCollection()->count($query); } else { return $this->getCollection()->count(); } } }