Skip to content

Implement Chain::merge(...$arrays) #54

@dretsa

Description

@dretsa

I have a scenario where i need to merge multiple domain value objects and it would be handy if one could just do:

Chain::merge($object->getOutsidePhotos(), $object->getInsidePhotos())
    ->map(fn (Photo $photo) => $photo->getUrl())
    ->map(fn (string $url) => $this....);

compared to:

Chain::create(array_merge($object->getOutsidePhotos(), $object->getInsidePhotos()))
    ->map(fn (Photo $photo) => $photo->getUrl())
    ->map(fn (string $url) => $this....);

Also different function of merge can be implemented, for example according to Optimizing array merge operation you will get better speed if you do not use the array_merge function in large arrays, because of some conditions php check internally.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions