Implement Chain::merge(...$arrays)
Opened this issue · 0 comments
colorninja commented
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?