Doctrine\Search\Query::getSingleResult PHP Method

getSingleResult() public method

Execute search for single result and hydrate results if required.
public getSingleResult ( integer $hydrationMode = null ) : mixed
$hydrationMode integer
return mixed
    public function getSingleResult($hydrationMode = null)
    {
        $this->query->setSize(1);
        $results = $this->getResult($hydrationMode);
        if (count($results) < 1) {
            throw new NoResultException('No results found');
        }
        return $results[0];
    }