protected function fetchResult(\MongoDB\Driver\Cursor $results, string $username): \stdClass
    {
        $values = $results->toArray();
        if (count($values) > 1) {
            throw new \Caridea\Auth\Exception\UsernameAmbiguous($username);
        } elseif (count($values) == 0) {
            throw new \Caridea\Auth\Exception\UsernameNotFound($username);
        }
        return current($values);
    }
protected function fetchResult(\MongoDB\Driver\Cursor $results, string $username): \stdClass
    {
        $values = $results->toArray();
        if (count($values) > 1) {
            throw new \Caridea\Auth\Exception\UsernameAmbiguous($username);
        } elseif (count($values) == 0) {
            throw new \Caridea\Auth\Exception\UsernameNotFound($username);
        }
        return current($values);
    }
protected function fetchResult ( \ MongoDB \ Driver \ Cursor $ results , string $ username ) : \ stdClass { $ values = $ results -> toArray ( ) ; if ( count ( $ values ) > 1 ) { throw new \ Caridea \ Auth \ Exception \ UsernameAmbiguous ( $ username ) ; } elseif ( count ( $ values ) == 0 ) { throw new \ Caridea \ Auth \ Exception \ UsernameNotFound ( $ username ) ; } return current ( $ values ) ; }
Fetches a single result from the Mongo Cursor.

@param \MongoCursor $results The results
@param string $username The attempted username (for Exception purposes)
@return \stdClass A single MongoDB document
@throws \Caridea\Auth\Exception\UsernameAmbiguous If there is more than 1 result
@throws \Caridea\Auth\Exception\UsernameNotFound If there are 0 results
Fetches a single result from the Mongo Cursor .