public function limit($limit = null)
    {
        if ($limit) {
            if ($limit < 0) {
                $this->items = array_slice($this->items, $limit, abs($limit));
            }
            else {
                $this->items = array_slice($this->items, 0, $limit);
            }
        }

        return $this;
    }
public function limit($limit = null)
    {
        if ($limit) {
            if ($limit < 0) {
                $this->items = array_slice($this->items, $limit, abs($limit));
            }
            else {
                $this->items = array_slice($this->items, 0, $limit);
            }
        }

        return $this;
    }
public function limit ( $ limit = null ) { if ( $ limit ) { if ( $ limit < 0 ) { $ this -> items = array_slice ( $ this -> items , $ limit , abs ( $ limit ) ) ; } else { $ this -> items = array_slice ( $ this -> items , 0 , $ limit ) ; } } return $ this ; }
Limits the number of results.

@param int|null $limit
@return ElasticCollection
Limits the number of results .