/** * Returns the first object in the result set, if any. * * @return mixed The first object of the result set or NULL if the result set was empty * @api */ public function getFirst() { if (is_array($this->queryResult)) { $queryResult =& $this->queryResult; } else { $query = clone $this->query; $query->setLimit(1); $queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($query)); } return isset($queryResult[0]) ? $queryResult[0] : null; }