src/LdapTools/Query/LdapQuery.php
public function getSingleResult($hydratorType = HydratorFactory::TO_OBJECT)
    {
        $result = $this->execute($hydratorType);
        $count = ($result instanceof LdapObjectCollection) ? $result->count() : count($result);

        if ($count === 0) {
            throw new EmptyResultException('LDAP returned no results.');
        } elseif ($count > 1) {
            throw new MultiResultException(sprintf('Expected a single result but LDAP returned %s result(s).', $count));
        }

        return ($result instanceof LdapObjectCollection) ? $result->first() : reset($result);
    }
public function getSingleResult($hydratorType = HydratorFactory::TO_OBJECT)
    {
        $result = $this->execute($hydratorType);
        $count = ($result instanceof LdapObjectCollection) ? $result->count() : count($result);

        if ($count === 0) {
            throw new EmptyResultException('LDAP returned no results.');
        } elseif ($count > 1) {
            throw new MultiResultException(sprintf('Expected a single result but LDAP returned %s result(s).', $count));
        }

        return ($result instanceof LdapObjectCollection) ? $result->first() : reset($result);
    }
public function getSingleResult ( $ hydratorType = HydratorFactory :: TO_OBJECT ) { $ result = $ this -> execute ( $ hydratorType ) ; $ count = ( $ result instanceof LdapObjectCollection ) ? $ result -> count ( ) : count ( $ result ) ; if ( $ count === 0 ) { throw new EmptyResultException ( 'LDAP returned no results.' ) ; } elseif ( $ count > 1 ) { throw new MultiResultException ( sprintf ( 'Expected a single result but LDAP returned %s result(s).' , $ count ) ) ; } return ( $ result instanceof LdapObjectCollection ) ? $ result -> first ( ) : reset ( $ result ) ; }
Retrieve a single unique result from LDAP. If the result is empty or contains more than one entry, an exception
is thrown.

@param string $hydratorType A hyrdrator type constant from the factory.
@return array|\LdapTools\Object\LdapObject
@throws EmptyResultException
@throws MultiResultException
Retrieve a single unique result from LDAP . If the result is empty or contains more than one entry an exception is thrown .