/** * @param array $filter * @param array $options * * @return Persistable */ public function findOne(array $filter = [], array $options = []) { $options['typeMap'] = ['root' => 'array', 'document' => 'array', 'array' => 'array']; if ($bson = $this->collection->findOne($filter, $options)) { return $this->hydrator->hydrate($bson); } }
/** * @param array $filter * @param array $options * * @return \Traversable */ public function find(array $filter = [], array $options = []) { $cursor = $this->collection->find($filter, $options); $cursor->setTypeMap(['root' => 'array', 'document' => 'array', 'array' => 'array']); foreach ($cursor as $values) { (yield $this->hydrator->hydrate($values)); } }
/** * {@inheritdoc} */ public function current() { return $this->hydrator->hydrate($this->iterator->current()); }