Merges another collection to this collection.

@param  mixed   $collection   A collection.
@param  boolean $preserveKeys If `true` use the key value as a hash to avoid duplicates.

@return object                Return the merged collection.
353282
public function merge($collection, $preserveKeys = false)
    {
        foreach($collection as $key => $value) {
            $preserveKeys ? $this[$key] = $value : $this[] = $value;
        }
        return $this;
    }
462025
public function mergeWith(Collection $collection): Collection
    {
        $calledClass = get_called_class();

        if ($collection instanceof $calledClass) {
            foreach ($collection as $key => $object) {
                $this[$key] = $object;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this)));
        }

        return $this;
    }
1228181
public static function refine($collections)
    {
        $output = array();

        foreach ($collections as $k => $collection) {
            $output[$k]["key"]   = $collection['priorityName'];
            $output[$k]["value"] = $collection['message'];
        }

        return $output;
    }
257947
public function merge($data) : Collection
    {
        return static::create(array_merge($this->data, $this->convertToArray($data)));
    }
21354
public function sync($collection)
    {
        foreach ($collection as $item) {
            $result = true;
            $websiteId = $item->getWebsiteId();
            if ($this->helper->isEnabled($websiteId)) {
                $this->client = $this->helper->getWebsiteApiClient($websiteId);
                $importData = $this->serializer->unserialize($item->getImportData());

                if ($this->client) {
                    $key = $importData[0];
                    $collectionName = $item->getImportType();
                    $this->client->deleteContactsTransactionalData($key, $collectionName);
                    $this->_handleSingleItemAfterSync($item, $result);
                }
            }
        }
    }
406449
public function merge($items)
    {
        $dictionary = $this->getDictionary();

        foreach ($items as $item) {
            $dictionary[$item->getKey()] = $item;
        }

        return new static(array_values($dictionary));
    }
860482
function reverse ($preserveKeys = false)
  {
    $this->pack ();
    $this->it = $this->array_reverse_iterator ($this->data, $preserveKeys);
    unset ($this->data);
    return $this;
  }
348378
private function _collection($collection) {
    return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection;
  }
360797
public function transform($collection)
    {
        if (!$collection instanceof Collection) {
            // If given "collection" is an object we need to wrap it into an array, and pass into collection.
            $collection = new Collection(is_array($collection) ? $collection : [$collection]);
        }

        // If transform is declared or set, we can execute transform on his object.
        if ($this->hasTransformer()) {
            return $this->transform->executeOn($collection);
        }

        // Otherwise, we can return collection without transformation.
        return $collection;
    }
624732
private static function mergeToStorage(array $storage, $key, array $list): array
    {
        $storage[$key] = array_key_exists($key, $storage) === true ? array_merge($storage[$key], $list) : $list;

        return $storage;
    }
1203844
public function merge(AbstractCollection $collection)
    {
        if (is_subclass_of($collection, get_class($this)) === true || get_class($collection) === get_class($this)) {
            $newData = array_merge($this->dataPlaceHolder, $collection->getDataPlaceHolder());
            $this->dataPlaceHolder = $newData;
        } else {
            $msg = "Only collections with compliant types can be merged ";
            $msg.= "('" . get_class($this) . "' vs '" . get_class($collection) . "').";
            throw new InvalidArgumentException($msg);
        }
    }
1149768
public static function keysExist(array $collection, array $keys)
    {
        $collection = array_flip($collection);

        foreach ($keys as $key) {
            if (!in_array($key, $collection)) {
                return false;
            }
        }

        return true;
    }
2225
public function merge(array $items)
    {
        $this->items = $this->arrayMergeRecursive($this->items, $items);
        $this->nestedKeyCache = [];
    }
131288
public function mapCombine( $keys, $values )
    {
        return array_combine(
            array_map( $keys, $this->collection ),
            array_map( $values, $this->collection )
        );
    }
928383
function mergeKeys( &$originalKeys, $keys )
    {
        foreach ( $keys as $key )
        {
            if ( count( $key ) >= 2 )
                $originalKeys[$key[0]] = $key[1];
        }
    }
455210
public function saveMany($models)
    {
        // Convert to collection if array
        $models = is_array($models) ? collection($models) : $models;

        foreach ($models as &$model) {
            $model = $this->save($model);
        }

        return $models;
    }
1240916
public function keys($collection=null) {
    list($collection) = self::_wrapArgs(func_get_args(), 1);
    
    if(!is_object($collection) && !is_array($collection)) throw new Exception('Invalid object');
    
    return self::_wrap(array_keys((array) $collection));
  }