Merge facet counts from other response

@param $other
183873
private function mergeFacetFieldCounts($other)
    {
        $facetFields = (array)$other->facet_counts->facet_fields;

        foreach($facetFields as $facetName => $facetCounts) {
            $facetCounts = (array)$facetCounts;

            foreach($facetCounts as $facetId => $facetCount) {
                if (isset($this->facet_counts->facet_fields->$facetName->$facetId)) {
                    $this->facet_counts->facet_fields->$facetName->$facetId = max(
                        $this->facet_counts->facet_fields->$facetName->$facetId,
                        $facetCount
                    );
                } else {
                    $this->facet_counts->facet_fields->$facetName->$facetId = $facetCount;
                }
            }
        }

        if (isset($other->facet_counts->facet_ranges)) {

            $facetRanges = (array)$other->facet_counts->facet_ranges;

            foreach ($facetRanges as $facetName => $facetCounts) {
                $facetCounts = (array)$facetCounts->counts;

                if (!isset($this->facet_counts)) {
                    $this->facet_counts = new \stdClass();
                }
                if (!isset($this->facet_counts->facet_ranges)) {
                    $this->facet_counts->facet_ranges = new \stdClass();
                }
                if (!isset($this->facet_counts->facet_ranges->$facetName)) {
                    $this->facet_counts->facet_ranges->$facetName = new \stdClass();
                    $this->facet_counts->facet_ranges->$facetName->counts = new \stdClass();
                }

                foreach ($facetCounts as $facetId => $facetCount) {
                    if (isset($this->facet_counts->facet_ranges->$facetName->counts->$facetId)) {
                        $this->facet_counts->facet_ranges->$facetName->counts->$facetId = max(
                            $this->facet_counts->facet_ranges->$facetName->counts->$facetId,
                            $facetCount
                        );
                    } else {
                        $this->facet_counts->facet_ranges->$facetName->counts->$facetId = $facetCount;
                    }
                }
            }
        }

        if (isset($other->facet_counts->facet_intervals)) {

            $facetIntervals = (array)$other->facet_counts->facet_intervals;

            foreach ($facetIntervals as $facetName => $facetCounts) {
                $facetCounts = (array)$facetCounts;

                if (!isset($this->facet_counts)) {
                    $this->facet_counts = new \stdClass();
                }
                if (!isset($this->facet_counts->facet_intervals)) {
                    $this->facet_counts->facet_intervals = new \stdClass();
                }
                if (!isset($this->facet_counts->facet_intervals->$facetName)) {
                    $this->facet_counts->facet_intervals->$facetName = new \stdClass();
                }

                foreach ($facetCounts as $facetId => $facetCount) {
                    if (isset($this->facet_counts->facet_intervals->$facetName->$facetId)) {
                        $this->facet_counts->facet_intervals->$facetName->$facetId = max(
                            $this->facet_counts->facet_intervals->$facetName->$facetId,
                            $facetCount
                        );
                    } else {
                        $this->facet_counts->facet_intervals->$facetName->$facetId = $facetCount;
                    }
                }
            }
        }
    }
914366
public function copyTo(LayerManager $other) 
    {
        $other->color = $this->color;
        
        $layer = $this->topLayer;
        $previousCopy = null;
        
        while ($layer !== null) {
            $copy = new Layer(
                $layer->polygonId,
                $layer->color,
                $layer->winding,
                $layer->windingRule
                );
            
            if ($previousCopy === null) {
                $other->topLayer = $copy;
            }
            else {
                $previousCopy->nextLayer = $copy;
            }
            
            $previousCopy = $copy;
            $layer = $layer->nextLayer;
        }
    }
840764
def merge(self, other):
        """"""
        if not getattr(other, '_catalog', None):
            return  # NullTranslations() has no _catalog
        if self._catalog is None:
            # Take plural and _info from first catalog found
            self.plural = other.plural
            self._info = other._info.copy()
            self._catalog = other._catalog.copy()
        else:
            self._catalog.update(other._catalog)
189778
private void merge(ExecutionStatistics otherStatistics) {
        for (String s : otherStatistics.executionInfo.keySet())
        {
            TimingData thisStats = this.executionInfo.get(s);
            TimingData otherStats = otherStatistics.executionInfo.get(s);
            if(thisStats == null) {
                this.executionInfo.put(s,otherStats);
            } else {
                thisStats.merge(otherStats);
            }

        }
    }
674572
public function setRangeOther($other, $field = null)
    {
        $param = $this->buildParam('facet.range.other', $field);
        return $this->set($param, $other);
    }
1317323
public function prependAll($other): Seq
    {
        if (is_array($other)) {
            return new Seq(
                array_merge(
                    array_values($other),
                    $this->data
                )
            );
        }

        if ($other instanceof Seq) {
            return $other->appendAll($this->data);
        }

        throw new \InvalidArgumentException('`$other` must be `Seq` or `array`');
    }
754017
public function merge(ArrayObject $other, $recursive = TRUE) {
        foreach($other as $key => $value) {
            if($recursive && $this->offsetExists($key)) {
                $ownvalue = $this->offsetGet($key);
                if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) {
                    $ownvalue->merge($value, TRUE);
                    continue;
                }
            }

            $this->offsetSet($key, $value);
        }

        return $this;
    }
843357
public function multiply(TransformationInterface $other)
    {

        $this->a = $this->a * $other->getA() + $this->c * $other->getB();
        $this->b = $this->b * $other->getA() + $this->d * $other->getB();
        $this->c = $this->a * $other->getC() + $this->c * $other->getD();
        $this->d = $this->b * $other->getC() + $this->d * $other->getD();
        $this->tx = $this->a * $other->getTx() + $this->c * $other->getTy() + $this->tx;
        $this->ty = $this->b * $other->getTx() + $this->d * $other->getTy() + $this->ty;

        return $this;
    }
149651
public function merge(UnitOfWork $other)
    {
        if (!$this->uniqueId->equals($other->uniqueId)) {
            throw new \InvalidArgumentException(
                'Cannot merge units with different UIDs'
            );
        }

        $this->workload = new Workload(
            sprintf(
                '%s%s',
                $this->getQuery(),
                $other->getQuery()
            )
        );
    }
494887
public function mergeAnalysis(
        ClassAnalysis $other)
    {
        $this->bad_definitions = array_merge_recursive(
            $this->bad_definitions,
            $other->bad_definitions
        );
        $this->missing_definitions = array_merge_recursive(
            $this->missing_definitions,
            $other->missing_definitions
        );
    }
914326
public function merge(BulkLoader_Result $other)
    {
        $this->created = array_merge($this->created, $other->created);
        $this->updated = array_merge($this->updated, $other->updated);
        $this->deleted = array_merge($this->deleted, $other->deleted);
    }
585217
public function merge(Config $other)
    {
        $this->tables = array_merge($this->tables, $other->getTables());
    }
167394
public function merge(self $other = null)
    {
        // Create new item
        $new = $this->copyChildless();

        // Add all children from this item
        foreach ($this->getChildren() as $child) {
            /* @var NavigationItem $child */
            $new->addChild($child->merge((null != $other) ? $other->findChildren($child) : null));
        }

        // Add all children from the other item
        if (null != $other) {
            foreach ($other->getChildren() as $child) {
                /** @var NavigationItem $child */
                if (!$new->find($child)) {
                    $new->addChild($child->merge($this->copyChildless()));
                }
            }
        }

        return $new;
    }
863075
def merge(self, other):
        
        self.stats = set(self.stats)
        self.stats.update(set(other.stats))
        self.stats = list(self.stats)
        if other._error:
            self._error = True
598348
public function zipLeft($other)
    {
        if (count($other) !== count($this)) {
            throw new \InvalidArgumentException(
                'Both left and right must have same size.'
            );
        }

        if (is_array($other)) {
            $aKeys = array_keys($this->data);
            $other = new Dict($other);

            return new Dict(
                array_map(
                    function ($key) use ($other) {
                        $leftValue = $this->getOrElse($key);
                        $rightValue = $other->getOrElse($key);

                        return new Tuple([$rightValue, $leftValue]);
                    },
                    $aKeys
                )
            );
        }

        if ($other instanceof Dict) {
            return $other->zipLeft($this->data);
        }

        throw new \InvalidArgumentException('`$other` must be `Dict` or `array`');
    }
228659
public Statistics combine(Statistics other) {
        return new Statistics(
                this.loadCount + other.getLoadCount(),
                this.loadErrorCount + other.getLoadErrorCount(),
                this.batchInvokeCount + other.getBatchInvokeCount(),
                this.batchLoadCount + other.getBatchLoadCount(),
                this.batchLoadExceptionCount + other.getBatchLoadExceptionCount(),
                this.cacheHitCount + other.getCacheHitCount()
        );
    }
13518
public void combine(IntSummaryStatistics other) {
        count += other.count;
        sum += other.sum;
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }