public function random()
    {
        $count = $this->count();
        switch ($count) {
            case 0:
                return null;
            case 1:
                return $this->one();
            default:
                $cursor = $this->skip(mt_rand(0, $count - 1))->limit(1);
                $cursor->rewind();
                return $cursor->current();
        }
    }
public function random()
    {
        $count = $this->count();
        switch ($count) {
            case 0:
                return null;
            case 1:
                return $this->one();
            default:
                $cursor = $this->skip(mt_rand(0, $count - 1))->limit(1);
                $cursor->rewind();
                return $cursor->current();
        }
    }
public function random ( ) { $ count = $ this -> count ( ) ; switch ( $ count ) { case 0 : return null ; case 1 : return $ this -> one ( ) ; default : $ cursor = $ this -> skip ( mt_rand ( 0 , $ count - 1 ) ) -> limit ( 1 ) ; $ cursor -> rewind ( ) ; return $ cursor -> current ( ) ; } }
Get random document

@return Document|null
Get random document