lib/Elastica/Aggregation/AbstractAggregation.php
public function addAggregation(AbstractAggregation $aggregation): self
    {
        if ($aggregation instanceof GlobalAggregation) {
            throw new InvalidException('Global aggregators can only be placed as top level aggregators');
        }

        $this->_aggs[] = $aggregation;

        return $this;
    }
public function addAggregation(AbstractAggregation $aggregation): self
    {
        if ($aggregation instanceof GlobalAggregation) {
            throw new InvalidException('Global aggregators can only be placed as top level aggregators');
        }

        $this->_aggs[] = $aggregation;

        return $this;
    }
public function addAggregation ( AbstractAggregation $ aggregation ) : self { if ( $ aggregation instanceof GlobalAggregation ) { throw new InvalidException ( 'Global aggregators can only be placed as top level aggregators' ) ; } $ this -> _aggs [ ] = $ aggregation ; return $ this ; }
Add a sub-aggregation.

@param AbstractAggregation $aggregation

@throws \Elastica\Exception\InvalidException

@return $this
Add a sub - aggregation .